[comp.unix.questions] Unusual

david@ics.COM (David B. Lewis) (05/09/89)

The command 
	``
kills ksh when run at the command line or in a shell script.
csh and sh handle it fine.
	`echo pwd` 
and non-null arguments are handled fine.
I noticed this in a script which was in fact executing 
	cd ``

Is a null `` undefined? 
What can be expected of this construct across shells?

(I checked "Unix Shell Programming" by Kochan and Woods without
seeing anything relevent to the exceptional case.)
-- 
David B. Lewis david@ics.com ics!david@buita.bu.edu david%ics.UUCP@buita.bu.edu

"An organization designing a system will produce a copy of its own
communication structure." - Melvin Conway

ekrell@hector.UUCP (Eduardo Krell) (05/10/89)

In article <456@ics.COM> david@ics.COM (David B. Lewis) writes:

>The command 
>	``
>kills ksh when run at the command line or in a shell script.

I just tried this on a 4.3 BSD Vax and Sun-3 and Sun-4's running
SunOS 4.0.1, all with ksh-88. Nothing happened (ie, a `` command
gave me just another prompt; there was no core dump).

What version of ksh are you running and what system is it running on?
    
Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ

UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell@ulysses.att.com

twb@cbnewsh.ATT.COM (thomas.w.beattie) (05/10/89)

In article <456@ics.COM> david@ics.COM (David B. Lewis) writes:
>
>The command 
>	``
>kills ksh when run at the command line or in a shell script.
>csh and sh handle it fine.

I tried this in KSH88 on an AT&T 3B2 and it didn't exit (or kill) the shell.
Is this problem in older versions? different machines? or what?
---
Tom Beattie
att!hoqaa!twb
t.w.beattie@att.com

carroll@s.cs.uiuc.edu (05/11/89)

This is a problem with ksh-i. I fixed this a years or two ago, so my memory
is a little shaky (I don't do sysadm'ing anymore, so I don't have access
to the source anymore).

There is a procedure called "comsubst" which does command substitution, which
gets called during evaluation of `stuff`. It returns a pointer to a structure
that describes the result. The bug is that when comsubst is called on
the empty string (``), it returns a NULL pointer, which the routine which
calls it doesn't check for - it just immediately de-references it. What
happens then depends on the machine architecture. On the 3b family, location
0 is system memory but readable, so it just gets garbage, (always the same
garbage), which ends up not doing anything (acceptable). On other systems
(e.g., Sun's) location 0 is either not mapped or un-readable, so the
dereference causes a core dump. The solution we came up with was to put
a hack into comsubst that checked for the empty string, and changed it to
":" (a ksh-command that does nothing). I have no idea if this has been fixed
in ksh-88 or not. I will try to persuade the current sysadmins to let me
look and see what the fix was (we wrote all the details down when we fixed
it). You can try email to them at bogia@m.cs.uiuc.edu or walquist@m.cs.uiuc.edu

P.S. I sent Mr. Krell some email about this, but it must have sounded very
incoherent - sorry about that.

Alan M. Carroll                "And there you are
carroll@s.cs.uiuc.edu           Saying 'We have the Moon, so now the Stars...'"
CS Grad / U of Ill @ Urbana    ...{ucbvax,pur-ee,convex}!s.cs.uiuc.edu!carroll

ekrell@hector.UUCP (Eduardo Krell) (05/14/89)

In article <216000014@s.cs.uiuc.edu> carroll@s.cs.uiuc.edu writes:

>I have no idea if this has been fixed
>in ksh-88 or not.

It's fixed in ksh-88. I tested it on SUNs (3s and 4s), Vaxen, 3B2s,
386 PCs, etc. and it works fine.
    
Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ

UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell@ulysses.att.com