Mail Archives: djgpp-workers/2000/10/26/07:15:10
On Wed, 25 Oct 2000, Peter J. Farley III wrote:
> I have a pure bash test script that demonstrates the problem
> now. Based on the results below, I think this is what is happening in
> the original perl test (with no escapes):
>
> 1. perl calls the bash shell with the command "echo #foo"
> 2. Something about the "#" causes bash to ignore everything starting
> with the "#" character.
This 'something' is easily understandable, I think: # starts comments, in
bash and most other Unix shells. So yes, "echo foo # bar" will only output
'foo', but not '# bar'.
I've seen people claim that this was incorrect behaviour of 'echo', which
should output everything you write after it verbatim, without *any*
alterations other than quotation, $VARIABLE expansions and redirection.
Csh, e.g., behaves that way:
acp3bf-broeker ~> echo foo # bar
foo # bar
But bash doesn't do it that way, not even in 'POSIXLY_CORRECT' mode. If
you want to echo a '#' sign after a whitespace, you have to quote it.
> I begin to suspect there may be a lexing error here, where bash thinks
> the "#" is a comment character.
No, that's documented standard behaviour of Bourne-style sh. '#' is a
comment character, in shell scripts. I suspect that Perl testsuite
fragment's goal was exactly that: to check which school the user's shell
is in.
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -