🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #792

bahs 1.04 core dumps reading a script file

#792
From: Andrew Thomas
Date: Fri, 01 Dec 1989 23:09
53 lines
1788 bytes
Running bash 1.04 on a uVaxII, Ultrix 2.0

I have a shell file which is read when I log in to set my functions.
This one causes a core dump;

------------------------
function distr ()
{
  local machines='watnext watsnew watsup watever watif watsleft'
  local current=`/bin/hostname`
  local curdir=$PWD
  if [ "$1" = "-m" ] ; then
    shift
    machines="$1"
    shift
  done							<-- should be fi
  if [ -z "$1" ] ; then
    echo "Usage: distr [-m machine] <file> [file...]"
    return
  fi
  for file in $* ; do
    if [ ! -f "$file" ] ; then
      echo Distr: $file: not a plain file.
    else
      for i in $machines ; do
        if [ "$i" != "$current" ] ; then
          echo cp -p $file /nfs/${i}${curdir}/$file
          cp -p $file /nfs/${i}${curdir}/$file
        fi
      done
    fi
  done
}
-----------------------------------------

I marked the error in the script, 'done' instead of 'fi'.  It should
still not produce a crash.  The output from bash is:

watsnew.2.102> bash -norc
bash$ . ./tshell
syntax error near `done'
./tshell:10: `  done'
Usage: distr [-m machine] <file> [file...]
can only `return' from a function
syntax error near `}'
./tshell:27: `}'
watsnew.2.103> 

--

Andrew Thomas
andrewt@watsnew.waterloo.edu	Systems Design Eng.	University of Waterloo
"If a million people do a stupid thing, it's still a stupid thing." - Opus
Technical Details
Message-ID: <ANDREWT.89Dec1180936@watsnew.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watcgl!andrewt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watcgl!andrewt
From: andrewt@watsnew.waterloo.edu (Andrew Thomas)
Newsgroups: gnu.bash.bug
Subject: bahs 1.04 core dumps reading a script file
Message-ID: <ANDREWT.89Dec1180936@watsnew.waterloo.edu>
Date: 1 Dec 89 23:09:36 GMT
Sender: daemon@watcgl.waterloo.edu
Organization: University of Waterloo, Waterloo, Ontario, Canada
Lines: 53