On 28/01/2016 20:22, Eric Blake wrote:
On 01/28/2016 01:17 PM, Ken Brown wrote:
install-info $f /usr/share/info/dir ||
install-info --entry="* $$f ($f): $$f" $$f /usr/share/info/dir
First, what do those double dollar signs mean?
If this is from a Makefile snippet, it says that $f is a make
variable,
while $$ turns into a literal $f for the shell that make invokes
It's not a Makefile snippet; it's a snippet from a bash shell
script. Here's more context:
for f in /usr/share/info/*; do
case "$f" in
*\**)
;;
*/dir|*/dir.info*)
;;
*-[0123456789]*)
;;
*)
install-info $f /usr/share/info/dir ||
install-info --entry="* $$f ($f): $$f" $$f
/usr/share/info/dir
;;
esac
done
It looks to me like all those double dollar signs will just get
expanded to the PID of the bash process, so that the second
install-info command is nonsense. But maybe I'm missing something.
Oooh, scary. Yeah, it looks like utter nonsense, as that would indeed
give the PID of bash followed by a literal f, but who wants to look up
info of '1234f'? I wonder if someone writing the script copied
incorrectly from a Makefile?
Crazy. I didn't add this part, so I guess it's been there for a long
time.
Second, why is the second line needed, i.e., under what circumstances
would it be expected to succeed after the first install-info command
failed?
Sadly, I don't know install-info enough to answer that one.
I think the first install-info command would fail if the .info file is
missing a START-INFO-DIR-ENTRY/END-INFO-DIR-ENTRY block, in which case
install-info should fail with a 'install-info: warning: no info dir
entry in `xxx.info''
Since such a .info file is apparently valid (although I don't think we
have any instances of such), I guess the nonsense after the || should be
fixed to use '$f' correctly.