rick@digibd.com (Rick Richardson) (05/19/91)
Here's a nasty little surprise I discovered when porting some
Bourne shell code from SVR3 to SVR4. The tidbit below serves only
to demonstrate the bug. The real code did something useful,
at least it did on SVR3. :-)
I checked UHC and AT&T flavors of SVR4. Don't know how many
others have the bug.
-Rick
#---------------
#
# Demonstrates bug in SVR4 /bin/sh
# Works OK with /bin/sh on SVR3 and XENIX
# Works OK with /bin/ksh on SVR4
#
# Should output the first line of /etc/passwd four times
# Only does it three times on SVR4 and then hangs
#
# Seems to be related to changing fd0 in a function
#
read_by_func() {
exec 3<&0 0<$1
read x
echo $x
exec 0<&3 3<&-
}
exec 3<&0 0</etc/passwd
read x
echo $x
exec 0<&3 3<&-
exec 3<&0 0</etc/passwd
read x
echo $x
exec 0<&3 3<&-
read_by_func /etc/passwd
# Gets stuck here with /bin/sh...
read_by_func /etc/passwd
exit
#---------------
--
Rick Richardson Email: rick@digibd.com
Senior MTS Fax: (612) 943-0803
DigiBoard, Inc. Tel: (612) 943-5383
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 <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...
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
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