Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!ncrlnk!ncrcae!hubcap!gatech!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!pt.cs.cmu.edu!PLAY.MACH.CS.CMU.EDU!bsy From: bsy@PLAY.MACH.CS.CMU.EDU (Bennet Yee) Newsgroups: comp.unix.wizards Subject: Re: End-of-file character (was script > mumble) Message-ID: <3281@pt.cs.cmu.edu> Date: 11 Oct 88 22:21:18 GMT Article-I.D.: pt.3281 References: <4975@saturn.ucsc.edu> <503@quintus.UUCP> <1503@fireball.cs.vu.nl> Sender: netnews@pt.cs.cmu.edu Organization: Cranberry Melon Lines: 42 In article <1503@fireball.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >In article <503@quintus.UUCP> ok@quintus.UUCP (Richard A. O'Keefe) writes: >\... here's some source code: >[C source deleted] > >People, what happened to good old shell script programming? > >BSD: >sh -c 'stty all 2> /tmp/stty.$$; set `tail -1 /tmp/stty.$$`; > shift; shift; echo $9; /bin/rm /tmp/stty.$$' >SysV: >sh -c 'stty -a | sed -e "s/.*eof = \([^;]*\).*/\1/" -e q' > >BTW, this shows the SysV stty(1) command is favorable in one way: if stdout >isn't a tty, try stderr or stdin! (So we won't need the stupid temp file.) No no no no. With even BSD stty, you can do it all in one line w/o stupid tmp files: sh -c 'set `stty all 2>&1 >/dev/tty | tail -1`; shift; shift; echo $9' or, if you don't like the tail, you could also use sh -c 'stty all 2>&1 > /dev/tty | awk "{ last = \$NF } END { print last }"' What _did_ happen to good olde shell programming? -bsy -- Internet: bsy@cs.cmu.edu Bitnet: bsy%cs.cmu.edu%smtp@interbit CSnet: bsy%cs.cmu.edu@relay.cs.net Uucp: ...!seismo!cs.cmu.edu!bsy USPS: Bennet Yee, CS Dept, CMU, Pittsburgh, PA 15213-3890 Voice: (412) 268-7571