csh echo problem with backquotes
Andy Hisgen
hisgen at jumbo.dec.com
Fri Oct 27 08:55:24 AEST 1989
I'm having a problem with csh's echo command in combination with back-quote.
The version of Ultrix we're running is 3.1, the csh is:
% ls -l /usr/bin/csh
-r-xr-xr-x 1 root 94208 Nov 15 1988 /usr/bin/csh
When I type the command:
% echo "`date` Start" > echoproblem
every other character in the output file is \377, according to od(1):
% od -c echoproblem
0000000 377 T 377 h 377 u 377 377 O 377 c 377 t 377
0000020 377 2 377 6 377 377 1 377 5 377 : 377 1 377 3
0000040 377 : 377 4 377 7 377 377 P 377 D 377 T 377
0000060 377 1 377 9 377 8 377 9 377 377 S 377 t 377 a
0000100 377 r 377 t \n
0000105
This problem doesn't occur if I use /bin/echo instead of echo. Nor
does it occur if I write:
% set d = `date`
% echo "$d Start" > echoproblem
Here are some more test cases, starting first with cases that have the
\377 problem followed by cases that don't have the problem.
These tests seem to show that if an echo command has an argument
that uses back-quotes, then any other arguments that are quoted
(whether with double-quotes, single-quotes, or backslash) have
a \377 stuck in front of each character.
% echo hello > hellofile
% echo "`cat hellofile` Start" | od -c
0000000 377 h 377 e 377 l 377 l 377 o 377 377 S 377 t
0000020 377 a 377 r 377 t \n
0000027
% echo `date` "Start" | od -c
0000000 T h u O c t 2 6 1 5 : 3 7
0000020 : 4 5 P D T 1 9 8 9 377 S 377
0000040 t 377 a 377 r 377 t \n
0000050
% echo `date` 'Start' | od -c
0000000 T h u O c t 2 6 1 5 : 3 8
0000020 : 0 0 P D T 1 9 8 9 377 S 377
0000040 t 377 a 377 r 377 t \n
0000050
% echo `date` \Start | od -c
0000000 T h u O c t 2 6 1 5 : 3 8
0000020 : 1 3 P D T 1 9 8 9 377 S t
0000040 a r t \n
0000044
Test cases that do not have the problem:
% echo `date` Start | od -c
0000000 T h u O c t 2 6 1 5 : 3 9
0000020 : 0 3 P D T 1 9 8 9 S t a
0000040 r t \n
0000043
% echo `date` | od -c
0000000 T h u O c t 2 6 1 5 : 3 9
0000020 : 2 8 P D T 1 9 8 9 \n
0000035
%
Andy Hisgen
DEC Systems Research Center
hisgen at src.dec.com
DECSRC::HISGEN
More information about the Comp.unix.ultrix
mailing list