Re: process multiple files
2006-08-26, 16:53(+02), Steffen Schuler:
> Stephane Chazelas wrote:
>> On Wed, 23 Aug 2006 21:20:58 +0200, Steffen Schuler wrote:
>> There's nothing GNU specific above. However, the usage of echo
>> makes it incorrect, as it depends on how the GNU shell was
>> compiled.
>
> Thank you Stephane for this info. I didn't know what you wrote about
> echo.
[...]
That's in the FAQ.
echo is one of the least portable commands.
POSIX says that its behavior is unspecified.
UNIX says that it must behave like on System V where no option
is recognised, where \n, \b, \f... are expanded.
bash, by defaults behaves the BSD way. It is almost POSIX
conformant. The only problem being that echo -e doesn't output
"-e<LF>".
However you can compile bash so that its echo is more Unix
conformant (expands the \x), you can achieve the same by issuing
"shopts -s xpg_echo". However, it is still not POSIX nor UNIX as
echo -e doesn't output "-e".
More generally.
echo "$var"
doesn't output the content of $var followed by a newline
character unless $var doesn't start with a - or doesn't contain
any backslash character.
printf is the command that must be used instead of echo.
--
Stéphane
|