tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
POSIX.2, IFS and echo command
It's not a bug report, it's a search for enlightment.
KerTeX is used on many systems, and my own compilation/installation
framework uses a very limited subset of POSIX.2 utilities, starting of
course by sh(1).
With sh(1), and specially on NetBSD, I tend to expect this behavior:
$ line=$(printf "a\tb")
$ echo $line | od -a
0000000 a sp b nl
0000004
That is line, not between double quotes, is expanded; then field
splitting is done with default IFS and echo prints two arguments, and
prints them separated by a space.
It happens that dash(1) (at least one version) and when such a call
is done in a subshell invocation '(...)' keeps the tab separating a and
b---this is piped to a sed call and hence the regex is failing because
it expects spaces, not spaces or tabs.
I guess that the problem is with the implementation of echo as a
built-in, with "shortcuts", that is, it is not called with arguments in
an ellipsis or iterating other the arguments list.
But reading the description of the echo command in the Open Group
spec, I read nowhere with _what_ delimiter between them successive
arguments have to be printed by echo. All in all, an echo
concatenating arguments will be POSIX compliant, no?
Do I read incorrectly the spec?
TIA
--
Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
http://www.kergis.com/
http://kertex.kergis.com/
http://nunc-et-hic.fr/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C
Home |
Main Index |
Thread Index |
Old Index