bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnulib-tool: possible bug in detection of a working `echo' command


From: Stefano Lattarini
Subject: gnulib-tool: possible bug in detection of a working `echo' command
Date: Mon, 31 Aug 2009 15:35:32 +0200
User-agent: KMail/1.12.0 (Linux/2.6.26-1-686; KDE/4.3.0; i686; ; )

Hi everybody.

While skimming through the gnulib-tool source code, I spotted what
seems to be a minor bug in the code that looks for a "working"
`echo' command (i.e. an `echo' that doesn't interpret backslashes).
This is around line 700-710 in my copy of gnulib-tool, which should
be up-to-date w.r.t. the latest git version.

The bug is in this command:
  $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'
which should check if $CONFIG_SHELL (when set) has a usable `echo'
command.  But the way it's written, that test *always* succeds,
even if $CONFIG_SHELL has a broken `echo' builtin.  This is caused
by the  fact that the `\t' in there is *not* quoted (even if at a first
glace it might seem to be), and thus the backslash is removed by the
shell  *before* running $CONFIG_SHELL, which then run a test like:
  echo t | grep t > /dev/null
which of course succeds.

To properly check the `echo' builtin of $CONFIG_SHELL, the command 
should be rewritten as e.g.:
  $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"
or:
  $CONFIG_SHELL -c 'echo '\''\t'\'' | grep t > /dev/null'

Regards,
    Stefano




reply via email to

[Prev in Thread] Current Thread [Next in Thread]