Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!zephyr.ens.tek.com!tektronix!reed!trost From: trost@reed.bitnet (Bill Trost) Newsgroups: gnu.bash.bug Subject: Strange behavior with functions Message-ID: <13771@reed.UUCP> Date: 19 Dec 89 23:46:35 GMT Sender: news@reed.UUCP Lines: 39 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.... :-)