Mail Archives: djgpp/1998/11/15/06:00:13
On Thu, 12 Nov 1998, Ian Chapman wrote:
> The line ... A="`echo | tr '\012' '\001'`" ... is to ensure
> portability. However what we have gives "unknown option to s".
``Portability'' my foot ;-).
This `tr' trick assumes that the empty line produced by `echo' holds a
single Newline character (octal code 012). But on DOS and Windows,
`echo' outputs the CR-LF pair (\015\012) instead. So after `tr' has
done its thing, A gets a string "\015\001", not a single character
001 as the script expects.
Here's a portable way to do this (should work on Unix as well):
A="`echo | tr -s '\015\012' '\001\001'`"
The `-s' magic is described in the Textutils manual.
- Raw text -