🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.bash.bug
Article #688

stopping and backgrounding shell functions

#688
From: Andrew Thomas
Date: Thu, 09 Nov 1989 22:08
46 lines
1828 bytes
I am using bash 1.04 on a uVaxII running Ultrix 2.0

If I attempt to stop a bash function using ^Z, the stop signal get sent to
the shell, causing it to stop if it is a non-login shell.  If the function
is executing an external command then that command is also stopped.

If I try to background a shell function using & on the command line, I get
an error listing like this:

local: can only be used in a function
local: can only be used in a function
describe_pid: No such pid (8064)!
local: can only be used in a function

because I used the local command in the shell function.

The shell function then runs, mails a message to maintainer, and core dumps.

The shell function in question is:

function distr ()
{
  local machines='watnext watsnew watsup watever watif watsleft'
  local current=`/bin/hostname`
  local curdir=$PWD
  if [ -z "$1" ] ; then
    echo Must provide at least one file name.
    return
  fi
  for file in $* ; do
    if [ ! -f "$file" ] ; then
      echo File: $file: not a plain file.
    else
      for i in $machines ; do
        if [ "$i" != "$current" ] ; then
          echo cp $file /nfs/${i}${curdir}/$file
          cp $file /nfs/${i}${curdir}/$file
        fi
      done
    fi
  done
}

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: <12244@watcgl.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watcgl!watnext!andrewt

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!watcgl!watnext!andrewt
From: andrewt@watnext.waterloo.edu (Andrew Thomas)
Newsgroups: gnu.bash.bug
Subject: stopping and backgrounding shell functions
Message-ID: <12244@watcgl.waterloo.edu>
Date: 9 Nov 89 22:08:50 GMT
Sender: daemon@watcgl.waterloo.edu
Reply-To: andrewt@watnext.waterloo.edu (Andrew Thomas)
Organization: U. of Waterloo, Ontario
Lines: 46