Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!sbphy.ai.mit.edu!bfox From: bfox@sbphy.ai.mit.edu (Brian Fox) Newsgroups: gnu.bash.bug Subject: Strange behavior with functions Message-ID: <8912201649.AA08712@sbphy.Ucsb.EDU> Date: 20 Dec 89 16:49:31 GMT References: <13771@reed.UUCP> Sender: daemon@tut.cis.ohio-state.edu Reply-To: bfox@ai.mit.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 51 Date: 19 Dec 89 23:46:35 GMT From: tektronix!reed!trost@cis.ohio-state.edu (Bill Trost) Sender: bug-bash-request@prep.ai.mit.edu The noise on alt.sources.wanted about file reversal made me come up with this little program: #!/local/bin/bash # Yes, all through this I should be using "$@", but that's for version # 1.05 (I have 1.04) rv () { [ $# = 0 ] && { # Call this block A local line=empty\?\?\? read line || return echo Read: "$line" 2>&1 rv echo "$line" # end A return } # Call this block B local f=$1 shift [ $# = 0 ] || rv $* rv < $f } rv $* Now, if I run this with no arguments (using /etc/motd as stdin), it works on the Decstation and longjmp botches after echoing "empty" on the Vax. If I run it with one argument, it does a longjmp botch after echoing "empty" on either machine. Then, if I swap blocks A and B and change the "&&" to a "||", with no arguments it works on the DECstation, but it prints "empty" for the first line and never prints the first line of the file (which should be printed last). Of course, Chet has probably already fixed it.... :-) Probably! But on the off chance that he hasn't, could you send me a typescript of the session? Thanks, Brian