由于“/usr/sbin/update-info-dir”中的错误,无法更新任何软件包

由于“/usr/sbin/update-info-dir”中的错误,无法更新任何软件包

由于“/usr/sbin/update-info-dir”中的错误,我无法更新 ubuntu 中的任何软件包

错误如下:

Setting up install-info (6.5.0.dfsg.1-2) ...
/usr/sbin/update-info-dir: 9: export: : bad variable name
dpkg: error processing package install-info (--configure):..........]
 installed install-info package post-installation script subprocess returned err
or exit status 2
Errors were encountered while processing:
 install-info
E: Sub-process /usr/bin/dpkg returned an error code (1)

这似乎表明问题出在第 9 行。前九行如下:

#!/bin/sh
# update-info-dir
# create a dir file from all installed info files
# Copyright 2009, 2014 Norbert Preining
# GPLv2

INFODIR=/usr/share/info

set -e

我在堆栈上看到过类似的问题,但它们并不完全相同。任何帮助都将不胜感激。

答案1

来源/usr/sbin/update-info-dir包括/etc/environment/etc/default/locale

错误很可能发生在其中一个文件的第 9 行 - 查找文件会导致错误报告中的行号混乱。例如,给定:

$ cat -n good.sh
     1  #!/bin/sh
     2
     3  . ./bad.environment

$ cat -n bad.environment
     1  # some comments
     2  #
     3  # more comments
     4  #
     5  # even more comments
     6  #
     7  #
     8
     9  export foo =bar

然后

$ ./good.sh
./good.sh: 9: export: : bad variable name

请注意,根据man environment.d(重点是我的):

CONFIGURATION FORMAT
       The configuration files contain a list of "KEY=VALUE" environment
       variable assignments, separated by newlines. The right hand side of
       these assignments may reference previously defined environment
       variables, using the "${OTHER_KEY}" and "$OTHER_KEY" format. It is also
       possible to use "${FOO:-DEFAULT_VALUE}" to expand in the same way as
       "${FOO}" unless the expansion would be empty, in which case it expands
       to DEFAULT_VALUE, and use "${FOO:+ALTERNATE_VALUE}" to expand to
       ALTERNATE_VALUE as long as "${FOO}" would have expanded to a non-empty
       value. No other elements of shell syntax are supported.

       Each KEY must be a valid variable name. Empty lines and lines beginning
       with the comment character "#" are ignored.

所以该/etc/environment文件根本不应该包含诸如此类的 shell 构造export

相关内容