[comp.unix.ultrix] csh echo problem with backquotes

hisgen@jumbo.dec.com (Andy Hisgen) (10/27/89)

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@src.dec.com
DECSRC::HISGEN

envbvs@epb2.lbl.gov (Brian V. Smith) (10/27/89)

< 
< I'm having a problem with csh's echo command in combination with back-quote.
< 
< % ls -l /usr/bin/csh
< -r-xr-xr-x  1 root        94208 Nov 15  1988 /usr/bin/csh
< 
< 
< % echo "`date` Start" > echoproblem
< 
< % 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
< 
[...]
< Andy Hisgen
< DEC Systems Research Center
< hisgen@src.dec.com
< DECSRC::HISGEN

Wait a minute!  You are from DEC and you don't know about this bug? 8-)
Actually I am surprised that it hasn't been fixed yet, as it was reported
in 3.0. Oh well.

The problem is apparently in the 8-bit character i/o that was attempted
in Ultrix 3.0.  It is a known bug when using `` and "" together. 
Let's hope that it is fixed in the next update.

_____________________________________
Brian V. Smith    (bvsmith@lbl.gov)
Lawrence Berkeley Laboratory
I don't speak for LBL, these non-opinions are all mine.

grr@cbmvax.UUCP (George Robbins) (10/27/89)

In article <14174@jumbo.dec.com> hisgen@jumbo.dec.com (Andy Hisgen) writes:
> 
> 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:
> % echo "`date` Start" > echoproblem
> 
> every other character in the output file is \377, according to od(1):

As has been pointed out, this is one of a number of quoting bugs that were
introduced by the changes to Ultrix/csh to support 8-bit transparency.  The
only known fix is to toss the new csh and either use a copy from a previous
release or use the /usr/new/csh (aka tcsh) which hasn't been improved in
this area.  The only real problem this causes is that this shell supports
and inactivity timout, so you may want to stick the setenv in your .login
to disable this...

-- 
George Robbins - now working for,	uucp: {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@uunet.uu.net
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)

jwb@lindenthal.cae.ri.cmu.edu (John Baugh) (10/28/89)

In article <8318@cbmvax.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
>release or use the /usr/new/csh (aka tcsh) which hasn't been improved in

/usr/new/csh is tcsh?  I'm using it but it doesn't seem to behave
like tcsh.  For example, emacs line editing works only when I do
an ESC to retrieve the previous command.  Otherwise (when I'm just
typing in a new command), none of the emacs bindings (e.g., ^A, ^E, ...)
work at all.  What am I doing wrong?  I have 'setenv CSHEDIT emacs'
in my .login.

John 'desperately seeking emacs command line editing' Baugh

Note: maybe I don't understand tcsh.  I've been using CMU's csh for
the last couple of years, and was under the impression that they
are similar.

grr@cbmvax.UUCP (George Robbins) (10/29/89)

In article <6727@pt.cs.cmu.edu> jwb@lindenthal.cae.ri.cmu.edu (John Baugh) writes:
> In article <8318@cbmvax.UUCP> grr@cbmvax.UUCP (George Robbins) writes:
> >release or use the /usr/new/csh (aka tcsh) which hasn't been improved in
> 
> /usr/new/csh is tcsh?  I'm using it but it doesn't seem to behave
> like tcsh.  For example, emacs line editing works only when I do
> an ESC to retrieve the previous command.

Maybe one should say "a tcsh".  I don't know the exact derivation of the
Ultrix /usr/new/csh, but prior to 3.x, it did command completion, which
the tcsh on our sun's did and then in 3.x, it sprouted command line
editing.  You may get some different action by applying the "tcsh patches"
to the Berkeley csh source, I dunno.  I don't use these features myself,
but it does seem to satisfy the desire for command completion that our Sun
users expect...

See man newcsh and /usr/new/Readme.newcsh for details.

-- 
George Robbins - now working for,	uucp: {uunet|pyramid|rutgers}!cbmvax!grr
but no way officially representing	arpa: cbmvax!grr@uunet.uu.net
Commodore, Engineering Department	fone: 215-431-9255 (only by moonlite)