Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Parameter expansion bug?



On Oct 31,  5:57pm, Hrvoje Niksic wrote:
} Subject: Re: Parameter expansion bug?
}
} Bart Schaefer (schaefer@xxxxxxxxxxxxxxxxxxxxxxx) wrote:
} > On Oct 31,  5:12pm, Zoltan Hidvegi wrote:
} > } How do you print -n under bash?
} > As nearly as I can tell, `echo -e -n` is the only way.
} 
} It doesn't work for me:
} 
} `-e' in bash is used to enable interpretation of control sequences
} like \n.

Yes, I know.

On Oct 31,  6:04pm, Zoltan Hidvegi wrote:
} Subject: Re: Parameter expansion bug?
}
} Perhaps you wanted to write
} 
} echo -e '\55n'

No, I see how I confused myself.  I was trying various combinations like
`echo \\-n` and got as far as:

bash$ echo -e -n\\n
-n

bash$ 

And then mistakenly though that this meant that only the first parameter
that began with a `-' was interpreted (e.g. that `echo -ne` was required
to get both escapes and no newline), and thus that `echo -e -n` would
work, when in fact it was the presence of the \\n that was causing the
second word to not be interpreted as a switch.

But `echo \\55n` is easier than `echo -ne -n\\n` ...

Interestingly, GNU echo ignores the -e switch; you have to give it -E to
shut off escapes.  So `echo ...` and `/bin/echo ...` aren't the same on
my machine, though they accept the same switches.  Isn't bash GNUware?

-- 
Bart Schaefer                             Brass Lantern Enterprises
http://www.well.com/user/barts            http://www.nbn.com/people/lantern



Messages sorted by: Reverse Date, Date, Thread, Author