[comp.unix.amiga] SVR4 /bin/sh BUG

bdb@becker.UUCP (Bruce D. Becker) (06/13/91)

In article <377@audfax.audiofax.com> arnold@audiofax.com (Arnold Robbins) writes:
|In article <1991Jun05.054111.27541@digibd.com> rick@digibd.com (Rick Richardson) writes:
||I'm also wondering why anyone was messing around with the shell code in
||the first place - I mean, if sh is no longer stable, one might as well bite
||the bullet and use ksh for the default root shell.
|
|Amen.  There's no reason to ship *three* stupid shells.  ksh should have
|been installed as /bin/sh and that's it.


	Agreed - so how about it Amiga unix guys,
	we all know it works; will you do this for
	the 2.0 release?


-- 
  ,u,	 Bruce Becker	Toronto, Ontario
a /i/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
 `\o\-e	 UUCP: ...!utai!mnetor!becker!bdb
 _< /_	 "Ferget yer humanity, do the poot" - devo

barrett@jhunix.HCF.JHU.EDU (Dan Barrett) (06/14/91)

>In article <377@audfax.audiofax.com> arnold@audiofax.com (Arnold Robbins) writes:
>|Amen.  There's no reason to ship *three* stupid shells.  ksh should have
>|been installed as /bin/sh and that's it.

	It's not necessary that simple.  You see, ksh is NOT an exact
superset of sh on all flavors of UNIX.  (I don't know about SVR4, though.)
Therefore, standard sh scripts can break under ksh.

	For example, the code:

		while [ foo ]
		do
			command
		done > outfile

spawns a subshell in sh, but not in ksh, on some flavors of UNIX.  This
can have a direct effect on variable values, for example.

                                                        Dan

 //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
| Dan Barrett, Department of Computer Science      Johns Hopkins University |
| INTERNET:   barrett@cs.jhu.edu           |                                |
| COMPUSERVE: >internet:barrett@cs.jhu.edu | UUCP:   barrett@jhunix.UUCP    |
 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\/////////////////////////////////////

jfh@greenber.austin.ibm.com (John F Haugh II) (06/14/91)

In article <109310@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:
>In article <377@audfax.audiofax.com> arnold@audiofax.com (Arnold Robbins) writes:
>|Amen.  There's no reason to ship *three* stupid shells.  ksh should have
>|been installed as /bin/sh and that's it.
>
>	Agreed - so how about it Amiga unix guys,
>	we all know it works; will you do this for
>	the 2.0 release?

This was tried internally with AIX v3 and found to fail pretty miserably.
It is my understanding that not only are the Bourne and Korn shells different
in many regards, but quite a few of the differences are both non-trivial and
easy to run into.
-- 
John F. Haugh II      |      I've Been Moved     |    MaBellNet: (512) 838-4340
SneakerNet: 809/1D064 |          AGAIN !         |      VNET: LCCB386 at AUSVMQ
BangNet: ..!cs.utexas.edu!ibmchs!auschs!snowball.austin.ibm.com!jfh (e-i-e-i-o)

bernie@metapro.DIALix.oz.au (Bernd Felsche) (06/14/91)

In <109310@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:

>	Agreed - so how about it Amiga unix guys,
>	we all know it works; will you do this for
>	the 2.0 release?

You will break compatabilty, and increase the system load. Compare the
object size of the Bourne and Korn shells.

I'd like the choice of having a heavyweight startup with "all the
fruit", or a quick start for "bare-bones". There is no need to weigh
down a simple interpreter with all the interactive niceties.

-- 
Bernd Felsche,                 _--_|\   #include <std/disclaimer.h>
Metapro Systems,              / sold \  Fax:   +61 9 472 3337
328 Albany Highway,           \_.--._/  Phone: +61 9 362 9355
Victoria Park,  Western Australia   v   Email: bernie@metapro.DIALix.oz.au

jet@karazm.math.uh.edu (J Eric Townsend) (06/15/91)

Gosh, why don't people just do the obvious:

whatever shell you want in /etc/passwd.
All shell scripts start with
#!/path/to/shell/that/this/script/should/be/run/thru


Granted, not all shell scripts have that, but doing
"sh filename" hasn't killed me yet.

Just another guy with csh in his /etc/passwd entry,

--
J. Eric Townsend - jet@uh.edu - bitnet: jet@UHOU - vox: (713) 749-2126
Skate UNIX! (curb fault: skater dumped)

   --  If you're hacking PowerGloves and Amigas, drop me a line. --

crash@ckctpa.UUCP (Frank J. Edwards) (06/15/91)

In article <109310@becker.UUCP> bdb@becker.UUCP (Bruce D. Becker) writes:
>In article <377@audfax.audiofax.com> arnold@audiofax.com (Arnold Robbins) writes:
>|Amen.  There's no reason to ship *three* stupid shells.  ksh should have
>|been installed as /bin/sh and that's it.
>
>	Agreed - so how about it Amiga unix guys,
>	we all know it works; will you do this for
>	the 2.0 release?

Watch it, there...  There are some pretty major differences in the way
sh and ksh handle certain operations that can cause seemingly simple
shell scripts to break.  For example,

	#!/bin/ksh
	#  add up everything in column two

	x=0
	while read field1 field2 junk
	do
		x=`expr $x + $field2`
	done
	echo $x

... works under ksh but not sh -- why?  (I'll let you stew over this
one for awhile before giving an answer >-} >-}

Some things are more obvious like "^" not being a pipe character to
ksh, or the semantics of function execution and/or traps within
functions.

And a compatriot of mine just upgraded his Sequent (alright, his company's
Sequent, but you know how administrators feel about _their_ machine ;-)
and his scripts broke because the vendor removed the built-in alias
for "echo" so his scripts were using /bin/echo which operates differently!

>-- 
>  ,u,	 Bruce Becker	Toronto, Ontario
>a /i/	 Internet: bdb@becker.UUCP, bruce@gpu.utcs.toronto.edu
> `\o\-e	 UUCP: ...!utai!mnetor!becker!bdb
> _< /_	 "Ferget yer humanity, do the poot" - devo

When I made ksh a hard link to /bin/sh it broke the scripts in the ~uucp
cleanup routines.  Try and figure out why "cd" and "pwd" would cause
the scripts to break...
-- 
Frank J. Edwards		|  "I did make up my own mind -- there
2677 Arjay Court		|   simply WASN'T ANY OTHER choice!"
Palm Harbor, FL  34684-4504	|		-- Me
Phone (813) 786-3675 (voice)	|    Only Amiga Makes It Possible...

crash@ckctpa.UUCP (Frank J. Edwards) (06/15/91)

In article <1991Jun15.014909.1562@menudo.uh.edu> jet@karazm.math.uh.edu (J Eric Townsend) writes:
>
>Just another guy with csh in his /etc/passwd entry,

Hmmm.  Perhaps this should be carried on through email since it isn't
specifically related to comp.unix.amiga, but I suppose if I get any
flames I can move it later ;-)

Why do *you* use csh?  What are the advantages (please be specific and
objective) of csh over ksh?

As an instructor (I teach Korn shell programming, Bourne shell programming,
other programming courses and some introductory user classes) I am most
interested in a "real world" opinion.

My story describes the path I took...

I first worked on an AT&T 3B2 which had only the Bourne shell, although
it did have the function ability.  I remember using variables all over
the place as shortcuts to typing (and retyping) long command lines.  I
also used shl, but that really is not an interactive command processor...

On the IBM RT that we got later the C shell was available, so I experimented
with it and found that it had numerous advantages, among them command
history, directory stacks, variables could be referenced as arrays, and
the {} characters as low-level string replacement wildcards.  I tried
to get the other programmers in my shop to switch over also, but they
were a little more entrenched in their ways (boy, I hope they're not
reading this! ;-)

Anyway, when ksh came out (on the RS/6000) that was my first taste.  There
is one thing that I miss from the C shell (the {} wildcards) but otherwise
the Korn shell seems much superior:  command history is "batch" as it
was in the C shell ("r vi" is the same as "!vi") except that an interactive
command history makes it much easier to visualize the command you're
constructing.  Directory stacks are emulated using functions, variables
can be created and accessed as arrays, the new wildcards @(), *(), +(),
?(), and !() are not quite as useful as {} but they come close.

A friend of mine once complained that ksh doesn't have any way of doing
the !$ feature of csh.  Not so; in "vi" mode, type <ESC>_ to insert
the last parameter or <ESC>3_ to insert the third parameter.

>--
>J. Eric Townsend - jet@uh.edu - bitnet: jet@UHOU - vox: (713) 749-2126
>Skate UNIX! (curb fault: skater dumped)
>
>   --  If you're hacking PowerGloves and Amigas, drop me a line. --

Sorry, I didn't mean it to be quite so long...  Again, if anyone is
interested in providing their views via email instead of posting, please
do so.  Thanks!
-- 
Frank J. Edwards		|  "I did make up my own mind -- there
2677 Arjay Court		|   simply WASN'T ANY OTHER choice!"
Palm Harbor, FL  34684-4504	|		-- Me
Phone (813) 786-3675 (voice)	|    Only Amiga Makes It Possible...

rhealey@kas.helios.mn.org (Rob Healey) (06/16/91)

>||I'm also wondering why anyone was messing around with the shell code in
>||the first place - I mean, if sh is no longer stable, one might as well bite
>||the bullet and use ksh for the default root shell.
>|Amen.  There's no reason to ship *three* stupid shells.  ksh should have
>|been installed as /bin/sh and that's it.
>	Agreed - so how about it Amiga unix guys,
>	we all know it works; will you do this for
>	the 2.0 release?
>
	Except that LOT'S of old shell scripts would break with ksh's
	interpretation of them. There are some NASTY subtle differences
	in the way Bourne and Korn do their work. And as pointed out
	in some other articles, ksh botches up too if the right conditions
	exist.

	You DO need 3 shells to keep EVERYONE happy and to remain a REAL
	R4 rather than a gee wiz rabid variant. Make ksh your default
	shell on ALL accounts for a while and see what happens, I think
	you'll find the results educational and enlightening. The sysadm
	scripts should be especially enlightening under ksh rather than sh...

	I hate backward compatability as much as the next guy, it kills
	innovation, but in this case I think it's premature to chuck sh and
	csh.

		My $0.000000002, adjusting for inflation and recession...

		-Rob

swarren@convex.com (Steve Warren) (06/17/91)

In article <1991Jun15.141609.848@ckctpa.UUCP> crash@ckctpa.UUCP (Frank J. Edwards) writes:
                                 [...]
>Why do *you* use csh?  What are the advantages (please be specific and
>objective) of csh over ksh?
                                 [...]

I got csh as my default shell on the first unix account I ever had.  So I
learned to write shell scripts in csh syntax.  Since then I have been required
to write many scripts in ksh syntax because our hardware diagnostic shell is a
superset of ksh.

I suppose that I am ruined because of the large number of csh scripts I have
written.  But the subtle distinctions in ksh on paren usage and placement of
whitespace in various circumstances always causes trouble for me.  I generally
have to write very short scripts that test my arithmetic expressions
seperately before I can include them in the rest of my scripts.  Often I find
myself mystified when I discover what it takes to get an expression to produce
the effect I desired.  For my purposes these distinctions are
counter-intuitive and cost me productivity.

Please note I am not a programmer; I am a hardware guy.  Of course there are
plenty of people here who swear by ksh.  But I prefer csh.

For my interactive shell I use tcsh, which provides me with interactive
benefits surpassing what ksh is currently capable of, while remaining
compatible with csh syntax.
--
            _.
--Steve   ._||__
  Warren   v\ *|
             V  

dave@jato.jpl.nasa.gov (Dave Hayes) (06/18/91)

crash@ckctpa.UUCP (Frank J. Edwards) writes:

>Why do *you* use csh?  What are the advantages (please be specific and
>objective) of csh over ksh?

Ksh doesn't have filename completion. (At least not that I know of)
This is from a person who uses ksh, csh, and tcsh.

-- 
Dave Hayes - Network & Communications Engineering - JPL / NASA - Pasadena CA
dave@elxr.jpl.nasa.gov       dave@jato.jpl.nasa.gov           ames!elroy!dxh

         Angels can fly because they take themselves lightly.

elliss@kira.egr.msu.edu (Stew Ellis) (06/18/91)

dave@jato.jpl.nasa.gov (Dave Hayes) writes:

>crash@ckctpa.UUCP (Frank J. Edwards) writes:

>>Why do *you* use csh?  What are the advantages (please be specific and
>>objective) of csh over ksh?

>Ksh doesn't have filename completion. (At least not that I know of)
>This is from a person who uses ksh, csh, and tcsh.

>-- 
>Dave Hayes - Network & Communications Engineering - JPL / NASA - Pasadena CA
>dave@elxr.jpl.nasa.gov       dave@jato.jpl.nasa.gov           ames!elroy!dxh

>         Angels can fly because they take themselves lightly.

Try <ESC><ESC>

That should fill out the name of a filename up to the point of ambiguity.

<ESC>*

will put all possible completions on the command line.

If these do not work with your ksh, please report the versions number.

------------------------------------------------------------------------
                                             _________________________________
  R.Stewart (Stew) Ellis                    / _______________________________/
  Assoc. Prof. of Social Science           / /      ______  ____________  __
  Dept. of Humanities & Social Science    / /      /___  / / ___  ___  / / /
  1700 W. Third Avenue                   / /          / / / /  / /  / / / /
  Flint, MI 48504                       / /__________/ / / /  / /  / / / /
  313-762-9765 Office                  /______________/ /_/  /_/  /_/ /_/

  elliss@frith.egr.msu.edu            ENGINEERING & MANAGEMENT INSTITUTE        

  "Apple Macintosh, the closed system for people with supposedly open minds."
    - plagiarized from someone else on the net
  "How you gonna do it? OS/2 it!" - stupid IBM ad 
  "Have you ever heard anything so half-OSsed?" - me

thad@public.BTR.COM (Thaddeus P. Floryan) (06/18/91)

In article <1991Jun17.234824.20461@jato.jpl.nasa.gov> dave@jato.jpl.nasa.gov writes:
>Ksh doesn't have filename completion. (At least not that I know of)
>This is from a person who uses ksh, csh, and tcsh.

Oh?  Perhaps you should get and read a copy of "The KORN Shell", Bolsky & Korn,
ISBN 0-13-516972-0, Prentice-Hall and AT&T, 1989.

The ksh (Version 06/03/86) on my 3B1/UNIXPC has filename completion as does
the ksh on the Sun machine from which I'm sending this response.

[Hint: see "set -o emacs"]

Thad Floryan [ thad@btr.com (OR) {decwrl, mips, fernwood}!btr!thad ]

crash@ckctpa.UUCP (Frank J. Edwards) (06/18/91)

In article <1991Jun17.234824.20461@jato.jpl.nasa.gov> dave@jato.jpl.nasa.gov writes:
>crash@ckctpa.UUCP (Frank J. Edwards) writes:
>>Why do *you* use csh?  What are the advantages (please be specific and
>>objective) of csh over ksh?
>
>Ksh doesn't have filename completion. (At least not that I know of)
>This is from a person who uses ksh, csh, and tcsh.

Ah, but it does!  When in the editing mode, ie. hit <ESC> if you've
set EDITOR=vi, you can type the following characters for fname completion:

	*	Causes a * to be appended to the current word and filename
		generation to be attempted.  If no match is found, ring the
		bell.  Otherwise replace the word with the matching file(s).
	
	\	Filename completion.  Replaces the current word with the
		longest common prefix of all filenames matching the current
		word if an asterisk had been appended.  If the match is
		unique:  a / is appended if its a directory, a space
		otherwise.
	
	=	List the filenames that would be generated by "*", above.

>Dave Hayes - Network & Communications Engineering - JPL / NASA - Pasadena CA
>dave@elxr.jpl.nasa.gov       dave@jato.jpl.nasa.gov           ames!elroy!dxh

[PS:  Thanks folks -- I kinda' expected "flames galore" from this request, but
that hasn't been the case (of course, my mail was redirect to /dev/null :-) ]
-- 
Frank J. Edwards		|  "I did make up my own mind -- there
2677 Arjay Court		|   simply WASN'T ANY OTHER choice!"
Palm Harbor, FL  34684-4504	|		-- Me
Phone (813) 786-3675 (voice)	|    Only Amiga Makes It Possible...

ag@amix.commodore.com (Keith Gabryelski) (06/18/91)

jet@karazm.math.uh.edu (J Eric Townsend) writes:
> [...] doing
> "sh filename" hasn't killed me yet.
> 
> Just another guy with csh in his /etc/passwd entry,

FYI, csh has the a shell variable named `shell' that keep the name of
shell to interpret non-system executable commands (ie, shell scripts).
If you typically use csh for interactive use and another (Bourne?) for
shell scripts use:

	set shell=/bin/sh

Pax, Keith
-- 
Keith Gabryelski                                 Advanced Products Group
ag@amix.commodore.com                                 ...!cbmvax!amix!ag

pd@x.co.uk (Paul Davey) (06/19/91)

-> crash@ckctpa.UUCP (Frank J. Edwards) writes:

>>Why do *you* use csh?  What are the advantages (please be specific and
>>objective) of csh over ksh?

Another advantage is that csh is more likely to be present, I work on
many machines, and like as standard an environment as is practicable.

Also ksh doesn't have the ability to refer to !-5:3 (not that I do
this very often but !131$ or !132* are very useful.
--
 Regards,			 pd@x.co.uk          IXI Limited
	Paul Davey		 pd@ixi.uucp         62-74 Burleigh St.
				 ...!uunet!ixi!pd    Cambridge  U.K.
 "These are interesting times"   +44 223 462 131     CB1  1OJ      
				 USA: 1 800 XDESK 57

crash@ckctpa.UUCP (Frank J. Edwards) (06/19/91)

In article <2671@amix.commodore.com> ag@amix.commodore.com (Keith Gabryelski) writes:
>FYI, csh has the a shell variable named `shell' that keep the name of
>shell to interpret non-system executable commands (ie, shell scripts).
>If you typically use csh for interactive use and another (Bourne?) for
>shell scripts use:
>
>	set shell=/bin/sh

Yes, but some csh implementations also require

	% alias shell=/bin/sh

which is prepended to any command line which attempts to exec() a file
which fails; the alias is prepended and the exec() is tried again.

Of course, this breaks other things in the shell (sigh).  Oh well, good
riddance to csh!

>Pax, Keith
>-- 
>Keith Gabryelski                                 Advanced Products Group
>ag@amix.commodore.com                                 ...!cbmvax!amix!ag

I did notice, though, that you Amix folks have fixed the SVR4 csh bug
concerning changing directory two levels into a symbolic link, and
then backing out again with "cd .."  My question is, "why in the world
did csh even care?!"  (Er, rhetorical question.  One does not ask _why_
the C shell does what it does...)
-- 
Frank J. Edwards		|  "I did make up my own mind -- there
2677 Arjay Court		|   simply WASN'T ANY OTHER choice!"
Palm Harbor, FL  34684-4504	|		-- Me
Phone (813) 786-3675 (voice)	|    Only Amiga Makes It Possible...

rhealey@kas.helios.mn.org (Rob Healey) (06/20/91)

In article <1991Jun17.234824.20461@jato.jpl.nasa.gov> dave@jato.jpl.nasa.gov writes:
>>Why do *you* use csh?  What are the advantages (please be specific and
>>objective) of csh over ksh?
>Ksh doesn't have filename completion. (At least not that I know of)
>This is from a person who uses ksh, csh, and tcsh.
>
	Bzzzzzzzzzzzzzzzzzzzzztt. But thank you for playing...

	ksh has had completion for quite a few revs, under vi mode
	type ESC followed by either an * or an = over the string
	you want completed.

	Admittedly, the completion is different from classic csh and
	tcsh completion and requires an extra keystoke or so. But,
	comming from a System V background and oodles of Bourne shell
	scripts, there's no real good reason not to use ksh.

	Comming from the BSD relm I could understand strong resistance
	to anything not csh based.

		-Rob

pjh@mccc.edu (Pete Holsberg) (06/22/91)

In article <PD.91Jun19125339@powys.x.co.uk> pd@x.co.uk (Paul Davey) writes:
=Also ksh doesn't have the ability to refer to !-5:3 (not that I do
=this very often but !131$ or !132* are very useful.

What do they mean?

Pete
-- 
Prof. Peter J. Holsberg      Mercer County Community College
Voice: 609-586-4800          Engineering Technology, Computers and Math
FAX: 609-586-6944            1200 Old Trenton Road, Trenton, NJ 08690
Internet: pjh@mccc.edu	     TCF 92 - April ??-??, 1992

pd@x.co.uk (Paul Davey) (06/25/91)

>>>>> On 21 Jun 91 17:17:11 GMT, pjh@mccc.edu (Pete Holsberg) said:

Pete> In article <PD.91Jun19125339@powys.x.co.uk> pd@x.co.uk (Paul Davey) writes:
Pete> =Also ksh doesn't have the ability to refer to !-5:3 (not that I do
Pete> =this very often but !131$ or !132* are very useful.

Pete> What do they mean?

Csh substitutions beginning with ! are history substitutions

The general form is (see csh(1) for accuracy - this is from memory)

	!<command specifier>[:]<modifier>...

In many cases the : is optional.

!131 means place the whole of command 131 on the command line, so with
no other text it just repeats command 131.

As well as absolute numbers as shown by the history command relative
numbers may be used. !:-3 is replaced by the command before last. !:-2
and !:-1 by the previous command. The !! command is also a sysnonym
for !:-2 (or !-1).

I find the absolute references more useful than the relative, of which
I usually only use !!. 

[ Note: !?foo can be used as a reference to the last command containing
the string foo, !bar refers to the last command starting with bar. ]

Possible modifiers include numbers which represent elements of the command

!<cs>:0 arg0
!<cs>:1 first argument
!<cs>:2 second argument
etc

!<cs>:$ last argument
!<cs>:* all argument

Colons can generally be omited where possible

so

 !131$ means the last argument of command 131
 !132* means the all arguments of command 132

 !-5:3 means the third argument of the fifth previous command
	(includes the command line under constructiuon)

Other modifiers may be used, :p is very useful, when added it makes
the whole command line Print, so it can be checked before execution.

It is added to the history list and can be executed with !!.

!*, !$, !?<string>* are all useful forms, if you know the rules.

eg 

1	vi verylongname.c foobar.c
2	cc -g !$
3	a.out
4	dbx !!
5	!!
6	vi !cc:$
7	indent !1*

--
 Regards,			 pd@x.co.uk          IXI Limited
	Paul Davey		 pd@ixi.uucp         62-74 Burleigh St.
				 ...!uunet!ixi!pd    Cambridge  U.K.
 "These are interesting times"   +44 223 462 131     CB1  1OJ      
				 USA: 1 800 XDESK 57