lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (08/04/88)
On the Sun 3/50's here at Ohio State University sh and ksh don't work correctly when echo is given a string that terminates with a \c. The output from: echo "Enter terminal type: \c" should be the line "Enter terminal type: " but not terminated with a new line (and with the "'s removed). This works in every other sh and ksh echo I've used. Anyone know what the problem is? Thanks, -- Larry Cipriani, AT&T Network Systems and Ohio State University Domain: lvc@tut.cis.ohio-state.edu Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (strange but true)
karish@denali.stanford.edu (Chuck Karish) (08/04/88)
In article <19256@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: >On the Sun 3/50's here at Ohio State University sh and ksh don't >work correctly when echo is given a string that terminates with >a \c. echo is a utility program, not a shell built-in, on SunOS. It sounds as if you're getting the BSD echo rather than the Sys5 echo. BSD echo suppresses the newline with the '-n' command line flag, not with a '\c' in the string. The manual page suggests that you choose the version you want by the placement of /usr/bin and /usr/5bin in your search path. I checked this on a machine that runs Version 3.2. Another approach, which should work anywhere, would be to do echo "Enter terminal type:" | tr '\012' ' ' Chuck Karish ARPA: karish@denali.stanford.edu BITNET: karish%denali@forsythe.stanford.edu UUCP: {decvax,hplabs!hpda}!mindcrf!karish USPS: 1825 California St. #5 Mountain View, CA 94041
ggs@ulysses.homer.nj.att.com (Griff Smith) (08/05/88)
In article <19256@tut.cis.ohio-state.edu>, lvc@tut.cis.ohio-state.edu.UUCP writes: > On the Sun 3/50's here at Ohio State University sh and ksh don't > work correctly when echo is given a string that terminates with > a \c. The output from: > > echo "Enter terminal type: \c" > > should be the line "Enter terminal type: " but not terminated with > a new line (and with the "'s removed). This works in every other > sh and ksh echo I've used. Anyone know what the problem is? > Thanks, | | -- | Larry Cipriani, AT&T Network Systems and Ohio State University | Domain: lvc@tut.cis.ohio-state.edu | Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (strange but true) This is an artifact of the BSD/Sys-V echo differences. Ksh has an ugly kludge in it that tries to guess which echo semantics are expected. You are expecting System V, the Sun is BSD (sort of). To get the System V semantics, put an empty executable file in your private bin (the one that is searched before the system bins) and call it "echo". Don't worry, it won't get executed. Ksh looks through the search list on start-up and makes notes about where it finds "echo". -- Griff Smith AT&T (Bell Laboratories), Murray Hill Phone: 1-201-582-7736 UUCP: {allegra|ihnp4}!ulysses!ggs Internet: ggs@ulysses.att.com
guy@gorodish.Sun.COM (Guy Harris) (08/05/88)
> On the Sun 3/50's here at Ohio State University sh and ksh don't > work correctly when echo is given a string that terminates with > a \c. The output from: > > echo "Enter terminal type: \c" > > should be the line "Enter terminal type: " but not terminated with > a new line (and with the "'s removed). This works in every other > sh and ksh echo I've used. Anyone know what the problem is? I can't speak for "ksh"; however, you've presumably not used a Version 7 UNIX shell, because "\c" doesn't do that in the V7 shell - you have to say echo -n "Enter terminal type: " The SunOS shell, starting in Release 3.2, can be made to support either form of echo. It pretends that "echo" is a regular command, rather than a built-in, that would reside either in "/bin" or in "/usr/5bin"; if it would have found the one in "/bin", it gives V7-style behavior with "-n" but no backslash escapes, and if it would have found the one in "/usr/5bin", it gives S5-style behavior with no "-n" but with backslash escapes including "\c". (Thanks and a tip of the Hatlo hat to Dave Korn for this trick. I don't know whether your "ksh" has this or not, since I don't know which "ksh" you have.) You can have your script set $PATH (shell scripts should always do that anyway, so they don't get surprised by non-standard $PATHs); however, this means you'd get the S5-environment versions of other commands as well, which may or may not be what you want.
ok@quintus.uucp (Richard A. O'Keefe) (08/05/88)
In article <19256@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: >On the Sun 3/50's here at Ohio State University sh and ksh [have trouble with] > echo "Enter terminal type: \c" Don't forget, AT&T "enhanced" echo(1) -- until it broke -- so there are *two* versions of echo in SunOS: /usr/bin/echo -- BSD version /usr/5bin/echo -- ATT version Just to confuse things, *both* versions echo are also built into sh. It works out which one you want by noting whether you search /usr/5bin before (you get the ATT version) or after (you get the BSD version) you search /usr/bin. THIS IS IN THE MANUAL PAGE FOR echo(1v). If you haven't already got /usr/5bin in your path, just do PATH=/usr/5bin:$PATH If you're used to System V, you'll probably want to do that anyway.
guy@gorodish.Sun.COM (Guy Harris) (08/05/88)
> echo is a utility program, not a shell built-in, on SunOS. Guess again. Ever since SunOS 3.0, the SunOS Bourne shell has been based on the System V shell (3.x has the S5R2 version, 4.0 has the S5R3.1 version), so "echo" is most definitely built into the SunOS Bourne shell. We also supply the "echo" utility, but then so does AT&T. > The manual page suggests that you choose the version you want by the > placement of /usr/bin and /usr/5bin in your search path. I checked > this on a machine that runs Version 3.2. Yup. This even affects the built-in versions, because of the trick mentioned in an earlier article. (From Griff Smith's article, it sounds as if the Korn shell's version of this trick involves actually looking for the "echo" program to see where it finds it, rather than just seeing whether "/usr/5bin" appears before "/bin" and "/usr/bin" in the path; the latter is what the SunOS Bourne shell does.)
daveb@laidbak.UUCP (Dave Burton) (08/05/88)
In article <19256@tut.cis.ohio-state.edu> lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) writes: |On the Sun 3/50's here at Ohio State University sh and ksh don't |work correctly when echo is given a string that terminates with |a \c. The output from: | | echo "Enter terminal type: \c" | |should be the line "Enter terminal type: " but not terminated with |a new line (and with the "'s removed). This works in every other |sh and ksh echo I've used. Anyone know what the problem is? SunOS is a 4BSD derived OS, and on 4BSD echo with no newline is echo -n "string " Sys3?, Sys5.x et.al. use echo "string \c" echo is not a builtin on earlier versions of sh (like the one with 4BSD), thus with sh, echo is /bin/echo ala 4BSD. echo is a builtin on ksh. ksh tries to configure itself to the target system at compile time. To maintain shell script compatability, the makefile determines which kind of echo /bin/echo is, then alters the compilation of ksh to that behaviour. -- Dave Burton | ``/* You are not expected to understand this. */'' ihnp4!laidbak!daveb | (312) 505-9100 x325 | Disclaimer: I channel only for myself.
lvc@tut.cis.ohio-state.edu (Lawrence V. Cipriani) (08/06/88)
In article <19256@tut.cis.ohio-state.edu>, I wrote: > On the Sun 3/50's here at Ohio State University sh and ksh don't > work correctly when echo is given a string that terminates with > a \c. The output from: > > echo "Enter terminal type: \c" > > should be the line "Enter terminal type: " but not terminated with > a new line (and with the "'s removed). This works in every other > sh and ksh echo I've used. Anyone know what the problem is? And I thought I was such a shell expert. Oh well, live and learn. I changed my profile to use: print -n "Enter terminal type: " I didn't want to fool around with the PATH since the same .profile is used to login on HP's running HP-UX, and a Pyramid running BSD and Suns running Sun OS. Isn't networking fun! Thanks to everyone that posted or emailed. -- Larry Cipriani, AT&T Network Systems and Ohio State University Domain: lvc@tut.cis.ohio-state.edu Path: ...!cbosgd!osu-cis!tut.cis.ohio-state.edu!lvc (strange but true)
davidsen@steinmetz.ge.com (William E. Davidsen Jr) (08/10/88)
On a Sun sh or ksh check to see if /usr/5bin is before /usr/bin and acts as if it were that type of echo. Rather than play with the PATH which I assume you have the way you want it, use: alias echo="print -" # for \c echo -or- alias echo=/bin/echo # for -n echo obviously this is for ksh only... -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs | seismo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me