Re: bash question ... echo subtleties
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 09 Dec 2007 19:31:49 GMT
On Sun, 09 Dec 2007 19:45:30 +0100, mallin.shetland wrote:
[...]
I like a '-' states 'end of argument', GNU prefers '--',
echo ignore both these conventions.
GNU and POSIX and every Unix. "-" states the "end of arguments"
only in a few utilities (including sh where "--" is supported as
well).
"-" is more often used to refer to stdin or stdout when used in
place of a file argument used for input or output respectively
(which is a pain as it means you need to take that into account
as in):
case $file1 in
(-*) file1=./$file1;;
esac
case $file2 in
(-*) file2=./$file2;;
esac
paste "$file1" "$file2"
Mark Hobley scrisse:[...]
I'll leave you to decide whether that is a bug or a feature (I say bug).
I think it is a POSIX feature. :P
No I *REALLY* think both 'echo -e ...' and 'echo -n ...' are
great mistakes but it is too late to do anything.
No, POSIX allows "-n" and says the behavior is unspecified if
it's provided. This is so that BSD shells are still POSIX
conformant, but of course that means you shouldn't use echo -n
in POSIX scripts. Other options like "-e" are not allowed by
POSIX and in that bash is not POSIX conformant. This is
intentional and claimed by GNU. "echo -n" is in the GNU standard
and you'll find that GNU doesn't discourage its usage.
Note that the Unix spec (SusV3 with XSI option) goes further in
that no option are supported (echo -n should output "-n<LF>")
but the Unix echo is also meant to expand the \n, \t, \f...
sequences, so that it can't be used reliably to output arbitrary
strings either.
--
Stephane
.
- Follow-Ups:
- Using dash and doubledash to end command line switches
- From: Mark Hobley
- Re: bash question ... echo subtleties
- From: mallin.shetland
- Using dash and doubledash to end command line switches
- References:
- bash question ... echo subtleties
- From: Yakov
- Re: bash question ... echo subtleties
- From: mallin.shetland
- Re: bash question ... echo subtleties
- From: Mark Hobley
- Re: bash question ... echo subtleties
- From: mallin.shetland
- bash question ... echo subtleties
- Prev by Date: Re: bash question ... echo subtleties
- Next by Date: Re: Script to find all soft links problem
- Previous by thread: Re: bash question ... echo subtleties
- Next by thread: Re: bash question ... echo subtleties
- Index(es):
Relevant Pages
|
|