Article View: comp.bugs.sys5
Article #650Bug in /bin/sh. Shell function redefinition in child.
From: erskine
Date: Thu, 03 Dec 1987 20:16
Date: Thu, 03 Dec 1987 20:16
74 lines
2600 bytes
2600 bytes
][b
---------- Files required to reproduce the problem:
$ cat init.dom
echo hello
. ./init.std
echo goodbye
exit 0
$ cat init.std
std_perms()
{
cat << --EOF--
--EOF--
}
$ cat newdom
. ./init.std
./init.dom
---------- To reproduce the problem:
Create the previous files in one directory, make them executable, and
from the Bourne Shell (/bin/sh) type
$ ./newdom
---------- I think the output should be:
$ ./newdom
hello
goodbye
$
---------- but on my system I get:
$
hello
./init.dom: shell memory fault$
---------- Commentary:
I'm running SCO Xenix System V version 2.2.1, and have found the
bug demonstrated by the accompanying files. By moving these files to
subdirectories, and making corresponding changes in the scripts, /bin/sh
goes into a tight CPU loop, disregarding signals.
The problem is that shell functions, unlike variables, get passed on
to child shell scripts. The redefinition of the shell function seems to
cause a big problem for sh if the function makes use of the << operator.
(But only if the function was inherited). Should the function definition
actually be inherited by child scripts? If yes, should shell variables also?
To check to see, add the command 'set' as the first line in init.dom.
If the functions are inherited, the definition of std_perms will be printed
along with the environment.
I phoned SCO who agreed that it is a bug, but who suggested that it
might be appropriate to forbid this usage (redefinition of a shell
function). I certainly haven't used many interpreters that didn't allow
redefinition of functions.
Most importantly, WHAT DOES YOUR /bin/sh DO? Please post to the net,
especially if yours doesn't inherit shell functions. If you don't HAVE
shell functions at all, LUCKY YOU, you don't have the bug! :-)
Neil
||!][b
---------
Neil S. Erskine MT&T - (902) 453-4915 x340
AP Computers USENET { garfield, watmath, ihnp4!utzoo!utai,
3845 Dutch Village Rd. uunet } !dalcs!force10!erskine
Halifax, N.S. B3L-4H9
Technical Details
Message-ID:
<625@force10.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!dalcs!force10!erskineShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!dalcs!force10!erskine From: erskine@force10.UUCP Newsgroups: comp.bugs.sys5,comp.unix.xenix Subject: Bug in /bin/sh. Shell function redefinition in child. Message-ID: <625@force10.UUCP> Date: Thu, 3-Dec-87 15:16:18 EST Article-I.D.: force10.625 Posted: Thu Dec 3 15:16:18 1987 Date-Received: Sun, 6-Dec-87 19:54:35 EST Organization: ForceTen Enterprises Lines: 76