MANPATH
的env-vars太长时,我遇到了以下错误的问题:
$> man <any command>
man: manpath list too long
要弄清路径列表太长的时候,我创建了这个小脚本:
#!/bin/bash
export MANPATH=
for i in $(seq 50 10000)
do
export MANPATH=/usr:$MANPATH
man -k gcc > /dev/null
[ $? -ne 0 ] && echo "$i ${#MANPATH}" && exit 0
done
似乎在${#MANPATH}
接近500时中断。
man -d
也没有提供我可以使用的任何信息...:(
我从没听说过(也没有发现)env-vars中的条目数限制(除了环境变量的最大长度之外,我还差得远)。
是否有针对此的修复程序?最好是非root用户的修复程序;)
我正在运行Debian 9.6。
编辑:这已在上游报告并解决!
答案 0 :(得分:1)
基于manp.c starting at line 786:
else if (sscanf (bp, "MANDATORY_MANPATH %511s", key) == 1)
add_mandatory (key);
else if (sscanf (bp, "MANPATH_MAP %511s %511s",
key, cont) == 2)
add_manpath_map (key, cont);
else if ((c = sscanf (bp, "MANDB_MAP %511s %511s",
key, cont)) > 0)
add_mandb_map (key, cont, c, user);
else if ((c = sscanf (bp, "DEFINE %511s %511[^\n]",
key, cont)) > 0)
add_def (key, cont, c, user);
else if (sscanf (bp, "SECTION %511[^\n]", cont) == 1)
add_sections (cont, user);
else if (sscanf (bp, "SECTIONS %511[^\n]", cont) == 1)
/* Since I keep getting it wrong ... */
...
我想说阈值是511个字符。有趣的是,有一条评论指出应该予以解决。
/* TODO: would like a (limited) replacement for sscanf()
* here that allocates its own memory. At that point check
* everything that sprintf()s manpath et al!
*/