diff options
author | jilles <jilles@FreeBSD.org> | 2011-02-04 22:47:55 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-02-04 22:47:55 +0000 |
commit | 95ad413d4a493285a5560182fb10217819d7c357 (patch) | |
tree | 88fab75180accb5d4fe09924cbd01e047b9e4903 /bin/sh/TOUR | |
parent | 88f7b7c78b4285a838792e26cf3806ab40f879d2 (diff) | |
download | FreeBSD-src-95ad413d4a493285a5560182fb10217819d7c357.zip FreeBSD-src-95ad413d4a493285a5560182fb10217819d7c357.tar.gz |
sh: Remove special code for shell scripts without magic number.
These are called "shell procedures" in the source.
If execve() failed with [ENOEXEC], the shell would reinitialize itself
and execute the program as a script. This requires a fair amount of code
which is not frequently used (most scripts have a #! magic number).
Therefore just execute a new instance of sh (_PATH_BSHELL) to run the
script.
Diffstat (limited to 'bin/sh/TOUR')
-rw-r--r-- | bin/sh/TOUR | 19 |
1 files changed, 1 insertions, 18 deletions
diff --git a/bin/sh/TOUR b/bin/sh/TOUR index af2773a..8448966 100644 --- a/bin/sh/TOUR +++ b/bin/sh/TOUR @@ -44,10 +44,6 @@ C source files for entries looking like: back to the main command loop */ } - SHELLPROC { - x = 3; /* executed when the shell runs a shell procedure */ - } - It pulls this code out into routines which are when particular events occur. The intent is to improve modularity by isolating the information about which modules need to be explicitly @@ -80,12 +76,7 @@ EXCEPTIONS: Code for dealing with exceptions appears in exceptions.c. The C language doesn't include exception handling, so I implement it using setjmp and longjmp. The global variable exception contains the type of exception. EXERROR is raised by -calling error. EXINT is an interrupt. EXSHELLPROC is an excep- -tion which is raised when a shell procedure is invoked. The pur- -pose of EXSHELLPROC is to perform the cleanup actions associated -with other exceptions. After these cleanup actions, the shell -can interpret a shell procedure itself without exec'ing a new -copy of the shell. +calling error. EXINT is an interrupt. INTERRUPTS: In an interactive shell, an interrupt will cause an EXINT exception to return to the main command loop. (Exception: @@ -270,14 +261,6 @@ When a program is run, the code in eval.c sticks any environment variables which precede the command (as in "PATH=xxx command") in the variable table as the simplest way to strip duplicates, and then calls "environment" to get the value of the environment. -There are two consequences of this. First, if an assignment to -PATH precedes the command, the value of PATH before the assign- -ment must be remembered and passed to shellexec. Second, if the -program turns out to be a shell procedure, the strings from the -environment variables which preceded the command must be pulled -out of the table and replaced with strings obtained from malloc, -since the former will automatically be freed when the stack (see -the entry on memalloc.c) is emptied. BUILTIN COMMANDS: The procedures for handling these are scat- tered throughout the code, depending on which location appears |