Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
/* $XConsortium: Makefile /main/3 1996/05/10 17:18:02 drk $ */
:MAKE: probe - cpp - *

View File

@@ -0,0 +1,95 @@
KSH-93 VS. KSH-88
The following is a list of known incompatibilities between ksh-93 and ksh-88.
I have not include cases that are clearly bugs in ksh-88. I also have
omitted features that are completely upward compatible.
1. Functions, defined with name() with ksh-93 are compatible with
the POSIX standard, not with ksh-88. No local variables are
permitted, and there is no separate scope. Functions defined
with the function name syntax, maintain compatibility.
This also affects function traces.
2. ! is now a reserved word. As a result, any command by that
name will no longer work with ksh-93.
3. The -x attribute of alias and typeset -f, is no longer
effective and the ENV file is only read for interactive
shells. You need to use FPATH to make function definitions
visible to scripts.
4. A built-in command named command has been added which is
always found before the PATH search. Any script which uses
this name as the name of a command (or function) will not
be compatible.
5. The output format for some built-ins has changed. In particular
the output format for set, typeset and alias now have single
quotes around values that have special characters. The output
for trap without arguments has a format that can be used as input.
6. With ksh-88, a dollar sign ($') followed by a single quote was
interpreted literally. Now it is an ANSI-C string. You
must quote the dollar sign to get the previous behavior.
Also, a $ in front of a " indicates that the string needs
to be translated for locales other than C or POSIX. The $
is ignored in the C and POSIX locale.
7. With ksh-88, tilde expansion did not take place inside ${...}.
with ksh-93, ${foo-~} will cause tilde expansion if foo is
not set. You need to escape the ~ for the previous behavior.
8. Some changes in the tokenizing rules where made that might
cause some scripts with previously ambiguous use of quoting
to produce syntax errors.
9. Programs that rely on specific exit values for the shell,
(rather than 0 or non-zero) may not be compatible. The
exit status for many shell failures has been changed.
10. Built-ins in ksh-88 were always executed before looking for
the command in the PATH variable. This is no longer true.
Thus, with ksh-93, if you have the current directory first
in your PATH, and you have a program named test in your
directory, it will be executed when you type test; the
built-in version will be run at the point /bin is found
in your PATH.
11. Some undocumented combinations of argument passing to ksh
builtins no longer works since ksh-93 is getopts conforming
with respect to its built-ins. For example, typeset -8i
previously would work as a synonym for typeset -i8.
12. Command substitution and arithmetic expansion are now performed
on PS1, PS3, and ENV when they are expanded. Thus, ` and $(
as part of the value of these variables must be preceded by a \
to preserve their previous behavior.
13. The ERRNO variable has been dropped.
14. If the file name following a redirection symbol contain pattern
characters they will only be expanded for interactive shells.
15. The arguments to a dot script will be restored when it completes.
16. The list of tracked aliases is not displayed with alias unless
the -t option is specified.
17. The POSIX standard requires that test "$arg" have exit status
of 0, if and only if $arg is null. However, since this breaks
programs that use test -t, ksh93 treats an explicit test -t
as if the user had entered test -t 1.
18. The ^T directive of emacs mode has been changed to work the
way it does in gnu-emacs.
19. ksh-88 allowed unbalanced parenthes within ${name op val} whereas
ksh-93 does not. Thus, ${foo-(} needs to be written as ${foo-\(}
which works with both versions.
20. kill -l in ksh-93 lists only the signal names, not their numerical
values.
I am interested in expanding this list so please let me know if you
uncover any others.

View File

@@ -0,0 +1,85 @@
/* $XConsortium: Makefile /main/3 1996/05/10 17:18:25 drk $ */
/*
* ksh makefile
* This makefile should work with nmake 2.3 and higher
*/
:PACKAGE: ast
.SOURCE : edit sh bltins data tests
.SOURCE.h : include
clobber = !(ksh) /* move ksh to ksh.old on clobber */
SH = ksh /* name of the shell program */
VERSION = 1.1
/* documentation files */
DOCFILES = sh.memo grep.mm builtins.mm README RELEASE COMPATIBILITY PROMO \
OBSOLETE RELEASEa
KSHELL == 1 /* this is ksh */
/* set these variables to 1 to enable, null to disable */
DEBUG == /* debugging purposes only */
MTRACE == /* on for malloc tracing */
SHOPT_ESH == 1 /* emacs/gmacs edit mode */
SHOPT_VSH == 1 /* vi edit mode */
SHOPT_SPAWN == /* use spawnve for fork/exec */
SHOPT_SUID_EXEC == 1 /* allow (safe) suid/sgid shell scripts */
/* use the following libraries only if they exist */
LIBS_opt := +lm +ljobs +li
if ! "$(-mam:N=static*)" && ! "$(HOSTTYPE:N=sgi.mips*)"
LIBS_opt += +lsocket +lnsl
end
LIBS_opt += -ldl -ldld +lintl
$(LIBS_opt) : .DONTCARE
LDLIBRARIES = $(LIBS_opt)
FILES_opt = /* optional file list enabled by vars above */
FILES_opt += $(SHOPT_ESH:T=V?emacs.c)
FILES_opt += $(SHOPT_VSH:T=V?vi.c)
/*
LDFLAGS += -u _XtAppInitialize -L/usr/add-on/X11/lib
*/
.ALL : $(SH) shcomp ksh.msg $(SHOPT_SUID_EXEC:T=V?suid_exec.c)
$(SH) :: sh.1 main.c -lshell +lcmd /* -lXaw -lXmu -lXt -lXtext -lX11 */ +last
DATAFILES = limits.c msg.c strdata.c testops.c keywords.c options.c \
signals.c aliases.c builtins.c variables.c lexstates.c
shell $(VERSION) :LIBRARY: nval.3 alarm.c cd_pwd.c cflow.c deparse.c \
getopts.c hist.c misc.c print.c read.c sleep.c trap.c test.c \
typeset.c ulimit.c umask.c whence.c \
arith.c args.c array.c completion.c dlopen.c defs.c edit.c expand.c \
fault.c fcin.c history.c init.c io.c jobs.c lex.c macro.c name.c \
parse.c path.c string.c streval.c subshell.c tdump.c timers.c \
trestore.c userinit.c waitevent.c xec.c $(DATAFILES) $(FILES_opt)
:READONLY: $(DATAFILES)
$(INCLUDEDIR) :INSTALLPROTO: nval.h shell.h
suid_exec :: suid_exec.c
shcomp :: shcomp.c -lshell -lcmd -last
ksh.msg : $(DATAFILES) /* build error message dictionary */
grep '[ ]e_[a-z].*".*[^\][a-z].*"' $(*) | grep -v /bin/ | grep -v /usr/ | grep -v /dev/ | grep -v /etc/ | grep -v A__z | sed 's/.*=[ ]*\(".*"\);.*/\1/' | sort | uniq > $(<)
grep '[ ]sh_opt.*".*[^\][a-z].*"' $(*) | sed 's/.*=[ ]*\(".*"\);.*/\1/' >> $(<)
grep '[ ]is_[a-z].*".*[^\][a-z].*"' $(*) | sed 's/.*=[ ]*\(".*"\);.*/\1/' >> $(<)
grep '[ ]e_notset' $(*) | sed 's/.*"....\(.*"\).*/"\1/' >> $(<)
grep '[ ]e_subst' $(*) | sed 's/.*"....\(.*"\).*/"\1/' >> $(<)
grep '[ ]e_file' $(*) | sed 's/.*"....\(.*"\).*/"\1/' >> $(<)
grep ',$' $(*:N=*signals.c) | sed 's/.*\(".*"\),/\1/' | sort | uniq >> $(<)
:: syscall.s mamexec mamstate.c apollo.c deparse.c ksh.mk OPTIONS $(DOCFILES)
$(TESTS):: alias.sh arith.sh arrays.sh attributes.sh basic.sh bracket.sh \
builtins.sh case.sh comvar.sh coprocess.sh exit.sh functions.sh \
grep.sh heredoc.sh io.sh options.sh quoting.sh return.sh select.sh \
substring.sh tilde.sh variables.sh nameref.sh shtests

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,152 @@
.sp 3
.tl ''Ksh Features That Are Obsolete in Ksh93''
.sp 2
.AL 1
.LI
Using a pair of grave accents \^\fB\(ga\fR ... \fB\(ga\fR\^
for command substition. Use \fB$(\fR ... \fB)\fR instead.
.LI
.B FCEDIT
is an obsolete name for
the default editor name for the
.B hist
command.
.B FCEDIT
is not used when
.B HISTEDIT
is set. Use
.B HISTEDIT
instead.
.LI
The newtest (\fB[[\fR ... \fB]]\fR) operator
\fB\-a\fP \fIfile\fP
is obsolete. Use
\fB\-e\fP instead.
.LI
The newtest (\fB[[\fR ... \fB]]\fR) operator
.BR = ,
as used in
\fIstring\fP \fB=\fP \fIpattern\fP
is obsolete. Use
\fB==\fP instead.
.LI
The following obsolete arithmetic comparisons are also permitted:
.in +5
.VL 20
.LI "\fIexp1\fP \fB\-eq\fP \fIexp2\fP"
True, if
.I exp1
is equal to
.IR exp2 .
.LI "\fIexp1\fP \fB\-ne\fP \fIexp2\fP"
True, if
.I exp1
is not equal to
.IR exp2 .
.LI "\fIexp1\fP \fB\-lt\fP \fIexp2\fP"
True, if
.I exp1
is less than
.IR exp2 .
.LI "\fIexp1\fP \fB\-gt\fP \fIexp2\fP"
True, if
.I exp1
is greater than
.IR exp2 .
.LI "\fIexp1\fP \fB\-le\fP \fIexp2\fP"
True, if
.I exp1
is less than or equal to
.IR exp2 .
.LI "\fIexp1\fP \fB\-ge\fP \fIexp2\fP"
True, if
.I exp1
is greater than or equal to
.IR exp2 .
.LE \" End .VL
.in -5
.LI
Using test -t or [ -t ] without specifying the file unit number.
.LI
The
.B \-k
option to the \fBset\fR builtin is obsolete. It causes
.I all\^
variable assignment arguments are placed in the environment,
even if they occur after the command name.
The following
first prints
.B "a=b c"
and then
.BR c :
There is no alternative.
.LI
The obsolete
.B \-xf
option of the
.B typeset
command allows a function to be exported
to scripts that are executed without a separate
invocation of the shell.
Functions that need to be defined across separate
invocations of the shell should
be placed in a directory and the
.B FPATH
variable should contains the name of this directory.
They may also
be specified in the
.B ENV
file with the
.B \-xf
option of
.BR typeset .
.LI
The shell environment variable
.B FCEDIT
is obsolete. Use
.B HISTEDIT
instead.
.LI
In the
.B \-s
option
(to \fBfc\fR or \fBhist\fR command???)
(
and in obsolete versions, the editor name
.B \-
)
is used to skip the editing phase and
to re-execute the command.
.LI
The
.B \-t
option to \fBalias\fR builtin is is obsolete. It
is used to set and list tracked aliases.
There is no replacement.
.LI
The shell command line option
.B \-t
is obsolete. This option cause the shell to exit after reading
and executing one command. The is no replacement (although ending
\&"command" with the exit builtin should have the same effect).
.LI
As an obsolete feature of the "set" builtin,
if the first
.I arg\^
is
.B \-
then the
.B \-x
and
.B \-v
options are turned off and the next
.I arg
is treated as the first argument.
Using
.B \+
rather than
.B \-
causes these options to be turned off.
These options can also be used upon invocation of the shell.
.LE

View File

@@ -0,0 +1,19 @@
ACCT= # accounting
ACCTFILE= # enable per user accounting info
BRACEPAT=1 # C-shell {...,...} expansions (note , required)
CRNL=0 # accept <cr><nl> for <nl>
DYNAMIC=1 # dynamic loading for builtins, requires dlopen()
ECHOPRINT=0 # make echo equivalent to print, overrides ECHO_N
ESH=1 # emacs edit option
FS_3D= # 3d file system
KIA=1 # shell information database generation
MULTIBYTE=1 # multibyte character handling
OLDTERMIO=0 # for systems that must support both TCGETA and TCGETS
OO=1 # partial object oriented extension, not complete
P_SUID=0 # real uid's that require -p flag for setuid/setgid
RAWONLY=0 # make viraw the only vi mode. Sometimes set automatically
SEVENBIT=0 # strip the eigth bit from characters
SPAWN=0 # use libast spawnve() in place of fork/exec when possible
SUID_EXEC=1 # execute /etc/suid_exec for suid, sgid script
TIMEOUT=0 # number of seconds for shell timeout, 0 disables feature
VSH=1 # vi edit option

View File

@@ -0,0 +1,147 @@
.SA 1
.sp 2
.ce
KSH-93 - The KornShell Command and Programming Language
.sp 2
.al
.P
KSH-93 is the most recent version of the KornShell Language
described in
"The KornShell Command and Programming Language,"
by Morris Bolsky and David Korn of AT&T Bell Laboratories, ISBN 0-13-182700-6.
The KornShell is a shell programming language,
which is upward compatible with "sh" (the Bourne Shell),
and is intended to conform to the IEEE P1003.2/ISO 9945.2 Shell and
Utilities standard.
KSH-93 provides an enhanced programming environment in
addition to the major command-entry features of the BSD
shell "csh". With KSH-93, medium-sized programming tasks can be
performed at shell-level without a significant loss in performance.
In addition, "sh" scripts can be run on KSH-93 without modification.
.P
The code should conform to the IEEE POSIX 1003.1 standard and to the
proposed ANSI-C standard so that it should be portable to all
such systems. Like the previous version, KSH-88,
it is designed to accept eight bit character sets
transparently, thereby making it internationally compatible.
It can support multi-byte characters sets with some characteristics
of the character set given at run time.
.P
KSH-93 provides the following features, many of which were also inherent
in KSH-88:
.BL
.LI
Enhanced Command Re-entry Capability: The KSH-93 history
function records commands entered at any shell level and stores
them, up to a user-specified limit, even after you log off.
This allows you to re-enter long commands with a few keystrokes
- even those commands you entered yesterday.
The history file allows for eight bit characters in
commands and supports essentially unlimited size histories.
.LI
In-line Editing: In "sh", the only way to fix mistyped
commands is to backspace or retype the line. KSH-93 allows you
to edit a command line using a choice of EMACS-TC or "vi"
functions.
You can use the in-line editors to complete filenames as
you type them.
You may also use this editing feature when entering
command lines from your history file.
A user can capture keystrokes and rebind keys to customize the
editing interface.
.LI
Extended I/O Capabilities: KSH-93 provides several I/O
capabilities not available in "sh", including the ability to:
.BL
.LI
specify a file descriptor for input and output
.LI
start up and run co-processes
.LI
produce a prompt at the terminal before a read
.LI
easily format and interpret responses to a menu
.LI
echo lines exactly as output without escape processing
.LI
format output using printf formats.
.LI
read and echo lines ending in "\e".
.LE
.LI
Improved performance: KSH-93 executes many scripts faster
than the System V Bourne shell. A major reason for this is
that many of the standard utilities are built-in.
To reduce the time to initiate a command, KSH-93 allows
commands to be added as built-ins at run time
on systems that support dynamic loading such as System V Release 4.
.LI
Arithmetic: KSH-93 allows you to do integer arithmetic in any
base from two to sixty-four. You can also do double
precision floating point arithmetic.
Almost the complete set of C language operators are available
with the same syntax and precedence.
Arithmetic expressions can be used to as an argument expansion
or as a separate command.
In addition there is an arithmetic for command that works
like the for statement in C.
.LI
Arrays: KSH-93 supports both indexed and associative arrays.
The subscript for an indexed array is an arithmetic expression,
whereas, the subscript for an associative array is a string.
.LI
Shell Functions and Aliases: Two mechanisms - functions and
aliases - can be used to assign a user-selected identifier to
an existing command or shell script.
Functions allow local variables and provide scoping
for exception handling.
Functions can be searched for and loaded on first reference the
way scripts are.
.LI
Substring Capabilities: KSH-93 allows you to create a
substring of any given string either by specifying the starting
offset and length, or by stripping off leading
or trailing substrings during parameter substitution.
You can also specify attributes, such as upper and lower case,
field width, and justification to shell variables.
.LI
More pattern matching capabilities: KSH-93 allows you to specify
extended regular expressions for file and string matches.
.LI
KSH-93 uses a hierarchal name space for variables.
Compound variables can be defined and variables can
be passed by reference. In addition, each variable
can have one or more disciplines associated with
it to intercept assignments and references.
.LI
Improved debugging: KSH-93 can generate line numbers on execution
traces. Also, I/O redirections are now traced.
There is a DEBUG trap that gets evaluated after each command
so that errors can be localized.
.LI
Job Control: On systems that support job control, including
System V Release 4, KSH-93
provides a job-control mechanism almost identical to that of
the BSD "csh", version 4.1.
This feature allows you
to stop and restart programs, and to move programs between the
foreground and the background.
.LI
Added security:
KSH-93 can execute scripts which do not have read permission
and scripts which have the setuid and/or setgid set when
invoked by name, rather than as an argument to the shell.
It is possible to log or control the execution of setuid and/or
setgid scripts.
The noclobber option prevents you from accidentally erasing
a file by redirecting to an existing file.
.LI
KSH-93 can be extended by adding built-in commands at run time.
In addition, KSH-93 can be used as a library that can
be embedded into an application to allow scripting.
.LE
Documentation for KSH-93 consists of an "Introduction to KSH-93",
"Compatibility with the Bourne Shell" and a manual page and a
README file. In addition, the "New KornShell Command and Programming
Language," book is available from Prentice Hall.

View File

@@ -0,0 +1,178 @@
/* $XConsortium: README /main/3 1996/07/15 14:14:10 drk $ */
This directory, and its subdirectories contain the source code
for ksh-93; the language described in the second addition of
the book, "The KornShell Command and Programming Language," by
Morris Bolsky and David Korn which is published by Prentice Hall.
ksh-93 has been compiled and run on several machines with several
operating systems. The end of this file contains a partial list of
operating systems and machines that ksh-93 has been known to run on.
The layout of files for ksh-93 has changed somewhat since ksh-88,
the last major release. Most of the source code for ksh remains in
the sh directory. However, the shell editing and history routines
are in the edit sub-directory. The code for shell built-ins is
in the bltins directory. The data directory contains read-only
data tables and messages that are used by the shell. The include
files remain in the include directory and the shlib directory
is gone. The feature directory replaces the older install
directory. The method for generating systems specific feature
information has changed substantially.
The OPTIONS file contains several options that can be set before
compiling ksh. This file is used to generate the FEATURE/options
include file. The OPTIONS are set to their recommended value.
A value of 0 represents off, 1 represents on.
The options have the following defaults and meanings:
ACCT off Shell accounting.
ACCTFILE off Enable per user accounting info
BRACEPAT on C-shell type abc{d,e}f style file generation
CRNL off <cr><nl> treated as <nl> in shell grammar.
DYNAMIC on Dynamic loading of builtins. (Requires dlopen() interface.)
ECHOPRINT off Make echo equivalent to print.
ESH on Compile with emacs command line editing. The original
emacs line editor code was provided by Mike Veach at IH.
FS_3D off For use with 3-D file system. Enabled automatically for
sytems with dynamic linking.
JOBS on Job notification, job control if possible.
KIA off Allow generation of shell cross reference database with -I.
MULTIBYTE on Multibyte character handling. Requires mblen() and mbctowc().
OLDTERMIO off Use either termios or termio at runtime.
P_SUID off If set, all real uids, greater than or equal to this
value will require the -p flag to run suid/sgid scripts.
RAWONLY off Turn on if the vi line mode doesn't work right unless
you do a set -o viraw.
SEVENBIT off Strip the eigth bit from characters.
SPAWN off Use spawn as combined fork/exec. May improve speed.
SUID_EXEC on Execute /etc/suid_exec for setuid, setgid script.
TIMEOUT off Set this to the number of seconds for timing out and
exiting the shell when you don't enter a command. If
non-zero, TMOUT can not be set larger than this value.
VSH on Compile with vi command line editing. The original vi
line editor code was provided by Pat Sullivan at CB.
The following compile options are set automatically by the feature testing:
DEVFD Set when /dev/fd is a directory that names open files.
SHELLMAGIC
Set on systems that recognize script beginning with #! specially.
VPIX Set on systems the have /usr/bin/vpix program for running MS-DOS.
In most instances, you will generate ksh from a higher level directory
which also generates libcmd and libast libraries on which ksh depends.
However, it is possible to generate ksh, with by running make -f ksh.mk
in this directory. The ksh.mk file was generated from the nmake Makefile.
If you do not have make or nmake, but do have a Version 7 UNIX compatible
shell, then you can run the script mamexec < Mamfile to build ksh.
If you have nmake, version 2.3 or later, you can use it without the -f ksh.mk.
In either case, ksh relies on libraries libast and libcmd which must be
built first. The binary for ksh becomes the file named ./ksh which can
be copied to where ever you install it.
If you use old make or the Mamfile, and you system has dynamic shared
libraries, then you should define the variables mam_cc_static and
mam_cc_dynanamic as the compiler options that request static linking
and dynamic linking respectively. This will decrease the number of
shared libraries that ksh need and cut startup time substantially.
The makefile should also generate shcomp, a program that will precompile
a script. ksh93 is able to recognize files in this format and process
them as scripts. You can use shcomp to send out scripts when you
don't want to give away the original script source.
It is advisable that you put the line PWD=$HOME;export PWD into the
/etc/profile file to reduce initialization time for ksh.
To be able to run setuid/setgid shell scripts, or scripts without read
permission, the SUID_EXEC compile option must be on, and ksh must be installed
in the /bin directory, the /usr/bin directory, the /usr/lbin directory,
or the /usr/local/bin directory and the name must end in sh. The program
suid_exec must be installed in the /etc directory, must be owned by root,
and must be a suid program. If you must install ksh in some other directory
and want to be able to run setuid/setgid and execute only scripts, then
you will have to change the source code file sh/suid_exec.c explicitly.
If you do not have ksh in one of these secure locations, /bin/sh will
be invoked with the -p options and will fail when you execute a setuid/setgid
and/or execute only script. Note, that ksh does not read the .profile
or $ENV file when it the real and effective user/group id's are not
equal.
The tests sub-directory contains a number of regression tests for ksh.
To run all these tests with the shell you just built, go to the tests
directory and run the command
SHELL=../ksh shtests
The file PROMO is an advertisement that extolls the virtues of ksh.
The file sh.1 contains the troff (man) description of this Shell.
The file nval.3 contains the troff (man) description of the name-value
pair library that is needed for writing built-ins that need to
access shell variables.
The file sh.memo contains a draft troff (mm) memo describing ksh. The
file RELEASE contains the changes made in this release since ksh-88.
The file COMPATIBILITY contains a list of incompatibilities with ksh-88.
The file bltins.mm is a draft troff (mm) memo describing how to write
built-in commands that can be loaded at run time.
Most of the work for internationalization has been done with ksh93.
The file ksh.msg is a generated file that contains error messages
that need to be translated. In addition, the function translate()
in sh/init.c has to be completed to interface with the dictionary
lookup. The translate function takes two argument, the string
that is to be translated and a type which is
0 when a library string needs translation.
1 when one of the error messages in ksh.msg needs translation.
2 when a string in a script needs translation. You use a $ in front
of a double quoted string in a script to indicate that it
needs translation. The -D option for ksh builds the dictionary.
The translate routine needs to return the translated message.
For dictionaries that need to use a numeric key, it should be
possible to use the strhash() function to generate numbers to
go along with each of the messages and to use this number both
when generating the dictionary and when converting strings.
If you encounter error messages of type 1 that are not be translated via
this translate() function send mail to the address below.
Please report any problems or suggestions to:
ksh@mozart.att.com
ksh93 has been compiled and alpha tested on the following. An asterisk
signifies that ksh has been installed as /bin/sh on this machine.
* Sun OS 4.1.[123] on sparc[12].
Sun OS 4.1.1 on sun3.
Solaris 2.[1234] on sparc2.
Solaris 2.4 on Intel 486..
HP/UX 8.05 on HP-9000/730.
HP/UX 9.01 on HP-9000/730.
HP/UX 9.00 on HP-9000/857.
System V Release 3 on Counterpoint C19
System V Release 4 on AT&T Intel 486.
System V Release 4 on NCR 4850 Intel 486.
IRIX Release 4.0.? System V on SGI-MIPS.
IRIX Release 5.1 System V on SGI-MIPS.
System V Release 3.2 on 3B2.
UTS 5.2.6 on Amdahl 3090,5990,580.
System V Release 3.2 on i386.
SMP_DC.OSx olivetti dcosx MIServer-S 2/128.
SMP_DC.OSx Pyramid dcosx MIServer-S 2/160 r3000.
4.3BSD on Vax 8650.
AIX release 2 on RS6000.
AIX 3.2 on RS6000.
Linux 1.1.59 on Intel 486
OSF1 on DEC alpha.
UMIPS 4.52 on mips.
BSD-i 2.0 on Intel 486.
NeXT on Intel 486.
NeXT on HP.
Windows NT with NutCracker libraries.
Windows NT with Portage libraries.
Windows NT using custom C library.
Windows 3.1 using custom C library.
Good luck!!
David Korn
dgk@research.att.com

View File

@@ -0,0 +1,422 @@
This is a list of changes that have been made since the 11/16/88 version
of ksh.
1. New features in 12/28/93
a. Associative arrays. The new version of ksh supports both
associate arrays and the older indexed arrays with the same
array syntax. A new -A option of typeset is used to declare
an array to be associative. As with indexed arrays, $name is
equivalent to ${name[0]}. The prefix operator ! was added
to the parameter expansion syntax to expand to the list of
indices. For example, ${!name[@]} expands to the list of array
indices for variable name.
b. Several additions have been made to shell arithmetic:
1. The shell now performs floating point arithmetic. The
typeset options -F and -E have been added for floating
point and scientific notation respectively.
2. The prefix and postfix ++ and -- operators.
3. The comma and ?: operators.
4. The math library functions.
5. An arithmetic for statement of the form
for ((expr1; expr2; expr3))
do ...
done
6. Integer arithmetic extended up to base 64.
c. Some additions to the macro expansion syntax have been made
to specify substrings and sub-arrays:
1. ${name:expr} expands to the substring of ${name} starting at
the character position defined by arithmetic expression expr.
2. ${name:expr1:expr2} expands to the substring of ${name} starting
at expr1 and consisting of at most expr2 characters.
3. ${name[@]:expr} expands to the values of ${name[@]} starting at
the element defined by arithmetic expression expr.
4. ${name[@]:expr1:expr2} expands to at most expr2 values of
${name} starting at expr1.
5. ${@:expr} expands the positional parameters starting at expr.
6. ${@:expr1:expr2} expands to at most expr2 positional parameters
starting at expr1.
7. ${!name} expands to the name of the variable named by name.
It will expand to name unless name is reference variable.
8. ${!name[sub]} expands to the name of the subscript of the
given variable. If sub is @ or * the list of subscripts
is generated.
9. ${!prefix*} and ${!prefix@} expand to the list of variable
names beginning with prefix.
10. The substring operators, # and % can be now be applied
with aggregates (@ or *) and are applied to each.
11. ${name/pattern/string} expands to the value of name with
the first occurrence of pattern replaced by string.
With aggregates (@ or *) this operation is applied to each.
12. ${name/#pattern/string} Same as above but the pattern
to be replaced must match at the beginning.
13. ${name/%pattern/string} Same as above but the pattern
to be replaced must match at the end.
14. ${name//pattern/string} expands to the value of name with
the each occurrence of pattern replaced by string.
With aggregates (@ or *) this operation is applied to each.
d. The name space for variables has been extended. The character '.'
can be used at the beginning of a name, and to separate identifiers
within a name. However, to create a name of the form, foo.bar,
the variable foo must exist. The namespace starting with .sh
is reserved for shell implementation variables. Exported
variable cannot contain a '.'.
e. Compound assignments. The assignment syntax, varname=value,
has been extended to allow assignments of the form
varname=(assignment_list). As elsewhere in the shell
spaces or tabs are optional around the parentheses, and
no space is permitted between the varname and the =. The
assignment_list can be one of the following:
1. A list of words. In this case each word is expanded as
in a for list and the resulting items become elements
of the indexed array varname.
2. A list of subscript assignments in the form
[subscript]=value. In this, these elements become
elements of the associative array varname.
3. A list of assignments; simple or compound. In this
case, each assignment is made to varname.name, where
name is the name of the enclosed assignment.
4. Assignments in the form of readonly or typeset
statements. In this case each assignment is made as
in 3 above, and the attributes are given to the
corresponding variable.
In case 3 and 4 above, the value of "$varname" after
the above assignment is (assignment_list), where the
assignment_list produced would reproduce all of the
variables under varname.*.
f. Function names of the form variable.action (called discipline
functions) can be defined where variable is any valid variable
name and action is get, set, or unset. The function variable.get
is invoked each time the variable is referenced. The set
discipline is invoked each time the variable is assigned to.
The unset discipline is invoked when a variable is unset.
The new variables .sh.name, .sh.subscript, and .sh.value are
defined inside the function body. Other shell extensions
may have their own set of discipline functions.
g. The compound command !, which negates the return value of the
following pipeline, has been added.
h. On systems that support dynamic loading with dlopen(), it is
now possible to add built-in commands at runtime with the
a builtin command named builtin.
i. The following builtins have been added:
1. command name [ ... ]
2. sleep [decimal-seconds]
3. builtin [-ds] [-f file] [name...]
4. getconf name [pathname]
5. disown [job...]
j. An addition format for literal strings, $'....' can
be used where ever literal strings are valid. The string
inside the single quotes will be converted using the ANSI-C
escape conventions. Additionally, the escape sequence \E
expands to the escape character (default \033) whenever ANSI-C
escape sequences are recognized.
k. A typeset -n option has been added which causes the value of a
variable to be treated as a reference to another variable so that
variables can be indirectly named. For example, if $1 contains
the name of a variable, then typeset -n foo=$1 causes the variable
foo to be synonymous with the variable whose name is $1. A builtin
alias, nameref='typeset -n' has been added to aid mnemonics.
Reference names cannot contain a '.'. Whenever that portion of
a variable up to the first '.' matches a reference name, the
reference value is substituted. For example, with nameref foo=.top,
then ${foo.bar} is equivalent to ${.top.bar}. When used as the
index of a for or select loop, each assignment causes a
new name reference to occur.
l. The KEYBD trap has been added which is triggered when a key
or escape sequence is typed while reading from the keyboard
in an edit mode. This, combined with some new variables
makes it possible to program your key bindings in ksh.
m. New variables have been added:
1. FIGNORE defines a set of file names to be ignored in each
directory when performing pathname expansion, replacing
the rule that requires that a leading . be matched explicitly.
2. Variable sh.edchar contains the value of the keyboard character
that has been entered when processing a KEYBD trap. If the value
is changed as part of the trap action, then the new value replaces
the key or keys that caused the trap.
3. Variable sh.edcol is set to the character position of the cursor
within the input buffer during a KEYBD trap.
4. Variable sh.edmode is set to the escape character when in vi
insert mode.
5. Variable sh.edtext is set to the contents of the input buffer
during a KEYBD trap.
6. HISTEDIT is checked before FCEDIT. FCEDIT is obsolete.
7. HISTCMD is the number of the current command in the history
file.
8. Variable .sh.version is set to the version string for
this shell.
9. Variable .sh.name is set to the name of the variable
that that was referenced or assigned to when executing a get
or set discipline function.
10. Variable .sh.subscript is set to the subscript for the variable
that was referenced or assign to when executing a get or
set discipline function.
11. Variable .sh.value is set to the new value for the variable
that was assigned to when executing the set discipline function.
n. New invocation and set -o options have been added:
1. set -o notify (or set -b) causes background completion messages
to be displayed as soon as the job completes.
2. There is a compile time option named KIA which enables
creation of a relational database for commands, variables
and functions defined and referenced by a script. The
option -I <filename>, causes the database to be generated
in <filename>. The database format can be queried via
the cql command.
o. ksh93 can read and evaluate pre-compiled scripts generated by
a separate program called shcomp.
p. More work on internationalization has been added:
1. The decimal point character is processed per locale
2. A $ can be placed in front of each string to indicate
that the string needs translation but is otherwise ignored.
This means that if a message catalog of all $"..." strings
is generated, then a program such as print $"hello world"
could display "bonjour monde" in the french locale.
q. Backreferences have been added to pattern matching. The sequence
\d, where d is a digit from 1-9, matches the same string as
the d-th previous parenthesis group. Backreferences
can be used within patterns, and within replacement strings
with any of the ${name/...} operators.
2. Changes made in 12/28/93
a. The output format of many commands has changed as follows:
1. System error messages are displayed whenever a failure
is caused by a system call.
2. The exit status has changed in many cases:
a. USAGE messages cause an exit status of 2.
b. Commands not found cause exit - 127.
c. Command found, but not executable - 126.
d. Terminated because of signal - 256+sig
3. The output of values from built-ins that contain special
characters are quoted in a manner that then can be re-input.
4. The trace output puts quotes around the output so that it
can be reused as input.
5. The output for trap is in a format that can be reinput the
the shell to restore the traps.
6. kill -l lists the signal names without numbers as
required by the POSIX standard.
b. The following changes have been made to shell functions:
1. The semantics of functions declared with name() has changed
to conform with the IEEE-POSIX 1003.2 standard. In particular,
these functions are executed in a dot script environment rather
than a separated function environment so that there are no
local variables and no scoping for traps.
2. Functions declared as function name, preserve the old ksh
semantics can be also used as the first argument to the dot (.)
command to have them executed in a dot script environment.
c. The command search rules have changed as follows:
1. Special built-ins (those with a dagger in front of them) are
executed first.
2. Functions are executed next.
3. Other built-ins that do not require an executable version
(for example cd and read) come next.
4. If the command name contains a slash, the pathname corresponding
to the command name is executed.
5. If name corresponds to a previously encountered pathname
on the PATH variable, the corresponding command is executed.
6. If the command name does not contain a slash, then the PATH
variable is used to find an executable by that name. If
the directory that the command is found is also contained in
the FPATH variable, then the command treated as a function.
If the shell has a built-in version of the command corresponding
to this command, then the built-in version of this command
is executed. Otherwise, the shell remembers that pathname
corresponding to this command name and executes this pathname.
7. If the name is not found on PATH, then the directories in
FPATH are searched. If found, then the command is executed
as a function.
d. Built-in commands options now conform to the IEEE-POSIX 1003.2
conventions with some additions. In particular,
name -?
will now print a Usage line for name, except for true, false,
colon, login, newgrp, echo, [, and command.
e. Tilde expansion is now performed as part of the word expansions.
The effect of this is that if word begins with ~ in ${name op word},
it will be expanded unless escaped.
f. Pathname expansion is no longer performed on redirection words
unless the shell is interactive.
g. Changes to shell and options:
1. The -n option has been enhanced to produce more warning and
portability messages.
2. The -C option is equivalent to -o noclobber. Files are
created with O_EXCL when -C is on.
h. The following changes have been made to [[...]]:
1. A string by itself is equivalent to -n string.
2. -e has been added as equivalent to -a.
3. == has been added as equivalent =.
4. -a and = are now considered obsolete.
5. Arithmetic comparisons are now considered obsolete.
i. kill has been changed as follows:
1. Signal names can be upper case or lower case.
2. Numerical arguments to kill -l cause the given signal names to
be displayed.
3. String arguments to kill -l cause the given signal numbers to
be displayed.
4. Synopsis changed for getopts conformance.
j. print has a -f format option which is equivalent to
the IEEE POSIX printf. Both print -f format, and
printf have the following extensions from IEEE POSIX:
1. Floating point formats are supported.
2. Size and precision specifications can be *.
3. The %d option can take an argument after precision to
specify the base that the number will be displayed.
4. A %q format can be used to output a string quoted so
that it can be re-input to the shell.
5. A %P format can be used to output the shell pattern which
corresponds to the give extended regular expression.
6. For numerical fields, the arguments can be arithmetic
expressions which will be evaluated.
7. The %n format works as described in ANSI-C.
k. The following changes have been made to fc:
1. It has been renamed hist. fc is now a predefined alias.
2. hist uses ${HISTEDIT:-$FCEDIT}. FCEDIT is obsolete.
3. A new -s option is equivalent to the obsolete -e -.
4. If the first argument refers to a command earlier than the
first accessible command, it now implies the first accessible
command, so that hist -l 1 lists all accessible history commands.
l. The dot command (.) has changed as follows:
1. The argument can be the name of a function declared as
function name. The function will execute without creating a
new scope.
2. If there are arguments to the given script or function,
the positional parameters are restored to their original
value when . completes.
m. The read built-in has been changed as follows:
1. A -A option to read has been added to allow the fields to be
read into an indexed array.
2. A -t n option has been added which causes read to
timeout after n seconds when reading from a slow device.
3. A -d char option has been added which causes the read
to terminate at char rather than at new-line.
n. The trap command has been changed as follows:
1. Trap names can be either upper case or lower case.
2. Trap -p cause only the specified trap values to be displayed.
3. The value of trap in a subshell will be the value in the parent
shell until a call to trap which changes the trap settings has
been made. Thus, savetraps=$(trap) works as required by the
POSIX standard.
o. The exec command has been extended as follows:
1. The -c option clears the environment first.
2. The -a name option sets argv[0] to name for the program.
p. true and false are built-ins, not aliases to built-ins.
q. test has been modified to conform to the IEEE-POSIX 1003.2
standard when there are three or less arguments.
r. umask -S option displays the mask in a symbolic format.
s. wait now returns the correct exit status of any previous
background job that has not been waited for, not just
the most recent one.
t. The whence built-in has an option -a which causes all
uses for the given command name to be reported.
u. unalias has -a option to clear all the aliases.
v. The times built-in command has been removed. The time
reserved word, without a command, gives time cumulative
time for the shell and its children. A built-in alias
for times should enable scripts using times to continue
to run.
w. Command substitution and arithmetic substitution will now be
performed for PS1, ENV, and PS4 evaluation in addition to
parameter expansion.
x. The SECONDS variable now displays elapsed time in floating
point seconds with 3 places after the decimal point by
default.
y. The getopts built-in now handles the complete libast optget
functionality. If any errors have occurred with getopts
when it has reached the end of arguments, then the Usage
message will be generated from the option string and the
exit status from getopts will be 2 rather than 1. The
usage message will be stored in the OPTARG variable if
the option string contains a leading colon; otherwise
it will be printed on standard error automatically.
z. THE ENV file is only processed for interactive shell
invocations. In addition, the -x attributes for
aliases and functions is ignored.
aa. The built-in edit modes have been changed as follows:
1. The pathname completion and pathname listing options
now perform command completion and command listing
when applied to a word in the command position.
2. In emacs mode ^N as the first related command after
the prompt will move to the next command relative to the
last known history position.
3. In emacs mode, successive kill and delete commands will
accumulate their data in the kill buffer, by appending or
prepending as appropriate. This mode will be reset by any
command not adding something to the kill buffer.
4. The control-T of emacs mode has been changed to behave like
control-T in gnu-emacs.
bb. The TMOUT variable also sets a limit for select timeouts
and default timeouts for read.
4. The source code has undergone significant modification.
a. Much of the code has been rewritten, In many cases this has
resulted in significant performance improvement.
b. The code is organized differently. See the README files
for more details.
c. Most configuration parameters now get generated using
the FEATURE mechanism of nmake. Other options are set
in the OPTIONS file.
c. The are several new compile time options. See the README
file for details. Some of the old ones have been removed.
d. The install script is a Mamfile that is generated by
nmake and processed by a script that comes with the
distribution.
e. There are far fewer global names. This should make it
must easier to add built-in commands without worrying
about conflicts.
f. The code uses the sfio library which makes it possible
to mix with stdio.
g. The code is written in ANSI C with full prototypes.
The code is based on the IEEE POSIX 1003.1 standard.
The code can be compiled with K&R C and with C++ by
using the ANSI cpp that comes with nmake or running
the code through the proto filter before pre-processing.
This happens automatically with our shipping system.
h. There is a programming interface for capturing references
and assignment to shell variables. It is also possible
to intercept variable creation and supply the array processing
function for that variable. See nval.3 for a description.

View File

@@ -0,0 +1,214 @@
This is a list of changes that have been made since the 12/28/93 version
of ksh.
1. New features in 12/28/93[b]
a. If IFS contains two consecutive identical characters belonging
to the [:space:] class, then this character is treated as
a non-space delimiter so that each instance will delimit
a field. For example, IFS=$'\t\t' will cause two consecutive
tabs to delimit a null field.
b. The getopts command has a -a name option that specifies a
name that will be used for usage messages.
2. Bugs fixed in 12/28/93a for default OPTIONS
a. An expansion bug which causes portions of a word after
a $((...)) expansion that contains a nested $var expansion
to be lost has been fixed.
b. A bug that caused a core dump when a script that did not
have PWD set and did a cd inside command substitution
has been fixed.
c. A bug which caused a core dump on some machines when
the LANG variable was assigned to has been fixed.
d. A bug which incorrectly handled set disciplines that
performed arithmetic evaluation when the discipline
was called from the arithmetic evaluator has been fixed.
e. A bug caused by an EXIT trap inside a function that
was executed in a subshell was fixed.
f. If foo is a function, and not a program, then command foo
now reports that foo isn't found rather than invoking foo.
g. The previous version incorrectly listed -A as an
invocation option. The -A option is only for set.
h. A bug was fixed which caused ksh to loop when execution trace
was enabled and the PS4 prompt required command substitution.
i. A bug which could cause the job control switch character
to be disabled when a script that enabled monitor mode
terminated was fixed.
j. A bug in the macro expansion global replacement operator //,
when the pattern began with a [ or +( has been fixed.
k. A bug which prevented ~ expansion from occurring when
it was terminated with a colon inside an assignment
has been fixed.
l. A bug in the dot command which prevented autoload functions
from working has been fixed.
m. A bug which caused a variable to be unset if the
its value were expanded inside a set discipline has
been fixed.
n. Whence -a now longer reports that a defined function
is undefined.
o. A bug on some systems in which $0 would be incorrect
in scripts invoked by name has been fixed.
p. Here documents with an empty body now work.
1. A bug which disabled argument passing and resetting
of options for a script invoked by name inside a
function has been fixed.
r. A bug in which an EXIT trap set the caller of a function
would be executed if a command called inside a function
was not found has been fixed.
s. A bug which allowed a script to trap signals that are
ignored at the time that the shell was invoked has
been fixed.
t. A bug which caused 2<&1- when applied to a shell built-in
to leave standard input closed has been fixed.
u. A bug which caused the shell to incorrectly parse
$() command substitutions with nested case statements
has been fixed.
3. Bugs fixed in 12/28/93b for default OPTIONS
a. A bug which caused unset RANDOM to dump core has been
fixed.
b. A bug which prevented return for terminating a profile
or ENV file has been fixed.
c. A bug which prevented standard input from being
directed to /dev/null for background jobs when
monitor mode was turned off has been fixed.
d. Statements of the form typeset -options var[expr]=value
did not perform substitutions on expr as expected.
e. A bug which prevented the shell from sending a HUP
signal to some background jobs that were not disowned
has been fixed.
f. A bug which allowed a script to trap signals that are
ignored at the time that the shell was invoked by exec
has been fixed.
g. A bug which could cause a core dump when a discipline
function was unset within a discipline was fixed.
h. The typeset builtin now accepts a first argument of
+ or - for compatibility with ksh88.
i. For compatibility with ksh88, the results of expansions
of command arguments will treat the extended character
match characters ()|& as ordinary characters.
j. A bug which caused read to fail on a file that was
open for read/write with <> when the first operation
was print or printf has been fixed.
k. When a job is suspended, it is put on the top of
the job list as required by the POSIX standard.
l. The value of OPTARG when an option that required
an argument but didn't have one was incorrect in the
case the the option string began with a :.
m. A bug which caused the terminal to get into a bad
state with some KEYBD traps in vi-mode has been fixed.
n. A bug which caused an invalid trap to cause a script
to terminate, rather than just return an error, has
been fixed.
o. Backreferencing sub-expressions in patterns and replacement
strings now works.
p. A bug in chmod which caused the -R option to fail has
been fixed.
4. Bugs fixed in 12/28/93c for default OPTIONS
a. The expansion of "$@" was incorrect when $1 was the null
string.
b. A bug which could incorrectly report a syntax error in
a backquoted expression when a $ was preceded by \\
has been fixed.
c. A bug which prevented the shell from exiting after
reporting an error when failing to open a script
has been fixed.
d. A bug that could lead to memory corruption when a
large here document that required parameter or command
substitution was expanded has been fixed.
e. A bug that could cause a core dump on some systems
after ksh detected an error when reading a function
has been fixed.
f. A bug which could cause a coprocess to hang when
reading from a process that has terminated has been fixed.
g. A bug which caused a script to terminate when set -e
was on and the first command of and && or || list
failed has been fixed.
h. A bug with here documents inside $(...) when the delimiter
word is an identifier has been fixed.
i. A bug which caused $0 to display the wrong value when
a script was invoked as an argument to the . command
and the eval command has been fixed.
j. A bug that could cause the built-in sleep to hang
has been fixed.
k. A bug introduces in 12/28/93b which caused the backslash
to be removed when it was followed by digit inside double
quotes in some instances has been fixed.
l. A bug which could cause a core dump if ksh was invoked with
standard input closed has been fixed.
m. A bug which could cause a core dump if typeset -A was
specified for an existing variable has been fixed.
n. Variables that were unset but had attributes such as readonly
and export were not listed with readonly, export and typeset.
o. Several problems with signals have been fixed.
p. A bug which prevented ulimit -t from working has been fixed.
Also, a bug in which failed ulimits could cause a core dump
has also been fixed.
q. A bug in expansion of the form ${name/#pattern/string} and
${name/%pattern/string} has been fixed.
r. A bug which caused read -r on a line that contained only
blanks to get a non-null value has been fixed.
s. A bug introduced in the 'a' point release in which
${x='\\'} expanded to \ when x was unset has been fixed.
t. A bug which prevented a trap on EXIT from being executed
when the last command in a script was a function invocation
has been fixed.
u. A bug which caused an interactive shell ignore input when
standard error was redirected to a file with exec,
and then restored with exec 2>&1 has been fixed.
v. An interactive shell turns on monitor mode even when
standard error has been redirected to a file.
w. A bug which could cause standard input to be incorrectly
positioned for the last command of a script has been fixed.
y. A bug in the edit modes which allowed walking back in
the history file for more than HISTSIZE commands has
beed fixed.
z. A bug which could cause a core dump if variable TMPDIR was
changed between two command substitutions has been fixed.
aa. A bug which prevented a trap on EXIT from being cleared
has been fixed.
5. Bugs fixed in 12/28/93d for default OPTIONS
a. The \ character was not handled correctly in replacement
patterns with ${x/pattern/replace}.
b. A bug with read in which the line did not end with
a new-line has been fixed.
c. A bug in file name generation which sometimes
appended a . for filenames that ended in / has
been fixed.
d. If a process is waited for after a status has
been returned by a previous wait, wait now
returns 127.
e. A bug with hist (fc) -e which prevented a command
to re-executed after it had been edited has been fixed.
f. A bug which prevented quoting from removint the meaning
of unary test operators has been fixed.
6. Bug fixes for specific non-default option combinations.
a. More signal names have been added for Solaris
b. A bug fixed for the v directive in vi MULTIBYTE has been
fixed.
c. Code to for IFS handling of multibyte characters has
been added.
d. The displaying of multibyte strings in export, readonly,
typeset, and execution traces has been fixed.
e. A bug with typeahead and KEYBOARD traps with the
MULTIBYTE option set has been fixed.
7. Other changes to 12/28/93[abcd]
a. A couple of minor changes to make adding built-ins easier.
b. Variables inside functions are now statically scoped.
The previous behavior was never documented.
c. A few changes have been made to the name-value library
that affect built-ins that use disciplines. The
changes allow disciplines to be shared by variables
and should make it possible to add new disciplines
without recompilation.
d. The name-value library interface has undergone significant
change for this revision. See the new nval.3 man page.
e. Builtin functions can take a third argument which is
a void*.
8. Incompatibilities with 12/28/93 version.
None intentional.

View File

@@ -0,0 +1,311 @@
/* $XConsortium: alarm.c /main/3 1995/11/01 16:27:14 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <error.h>
#include <stak.h>
#include "builtins.h"
#include "FEATURE/time"
#define R_FLAG 1
#define L_FLAG 2
struct tevent
{
Namfun_t fun;
Namval_t *node;
Namval_t *action;
struct tevent *next;
long milli;
int flags;
__V_ *timeout;
};
static const char ALARM[] = "alarm";
static void trap_timeout __PROTO__((__V_*));
/*
* insert timeout item on current given list in sorted order
*/
static __V_ *time_add __PARAM__((struct tevent *item, __V_ *list), (item, list)) __OTORP__(struct tevent *item; __V_ *list;){
register struct tevent *tp = (struct tevent*)list;
if(!tp || item->milli < tp->milli)
{
item->next = tp;
list = (__V_*)item;
}
else
{
while(tp->next && item->milli > tp->next->milli)
tp = tp->next;
item->next = tp->next;
tp->next = item;
}
tp = item;
tp->timeout = (__V_*)timeradd(tp->milli,tp->flags&R_FLAG,trap_timeout,(__V_*)tp);
return(list);
}
/*
* delete timeout item from current given list, delete timer
*/
static __V_ *time_delete __PARAM__((register struct tevent *item, __V_ *list), (item, list)) __OTORP__(register struct tevent *item; __V_ *list;){
register struct tevent *tp = (struct tevent*)list;
if(item==tp)
list = (__V_*)tp->next;
else
{
while(tp && tp->next != item)
tp = tp->next;
if(tp)
tp->next = item->next;
}
if(item->timeout)
timerdel((__V_*)item->timeout);
return(list);
}
static void print_alarms __PARAM__((__V_ *list), (list)) __OTORP__(__V_ *list;){
register struct tevent *tp = (struct tevent*)list;
while(tp)
{
if(tp->timeout)
{
register char *name = nv_name(tp->node);
if(tp->flags&R_FLAG)
{
double d = tp->milli;
sfprintf(sfstdout,e_alrm1,name,d/1000.);
}
else
sfprintf(sfstdout,e_alrm2,name,nv_getnum(tp->node));
}
tp = tp->next;
}
}
static void trap_timeout __PARAM__((__V_* handle), (handle)) __OTORP__(__V_* handle;){
register struct tevent *tp = (struct tevent*)handle;
sh.trapnote |= SH_SIGTRAP;
if(!(tp->flags&R_FLAG))
tp->timeout = 0;
tp->flags |= L_FLAG;
sh.sigflag[SIGALRM] |= SH_SIGTRAP;
if(sh_isstate(SH_TTYWAIT))
sh_timetraps();
}
void sh_timetraps __PARAM__((void), ()){
register struct tevent *tp, *tpnext;
register struct tevent *tptop;
while(1)
{
sh.sigflag[SIGALRM] &= ~SH_SIGTRAP;
tptop= (struct tevent*)sh.st.timetrap;
for(tp=tptop;tp;tp=tpnext)
{
tpnext = tp->next;
if(tp->flags&L_FLAG)
{
tp->flags &= ~L_FLAG;
if(tp->action)
sh_fun(tp->action,tp->node);
tp->flags &= ~L_FLAG;
if(!tp->flags)
{
nv_unset(tp->node);
nv_close(tp->node);
}
}
}
if(!(sh.sigflag[SIGALRM]&SH_SIGTRAP))
break;
}
}
/*
* This trap function catches "alarm" actions only
*/
static char *setdisc __PARAM__((Namval_t *np, const char *event, Namval_t* action, Namfun_t
*fp), (np, event, action, fp)) __OTORP__(Namval_t *np; const char *event; Namval_t* action; Namfun_t
*fp;){
register struct tevent *tp = (struct tevent*)fp;
if(!event)
return(action?"":(char*)ALARM);
if(strcmp(event,ALARM)!=0)
{
/* try the next level */
return(nv_setdisc(np, event, action, fp));
}
if(action==np)
action = tp->action;
else
tp->action = action;
return(action?(char*)action:"");
}
/*
* catch assignments and set alarm traps
*/
static void putval __PARAM__((Namval_t* np, const char* val, int flag, Namfun_t* fp), (np, val, flag, fp)) __OTORP__(Namval_t* np; const char* val; int flag; Namfun_t* fp;){
register struct tevent *tp;
register double d;
if(val)
{
double now;
#ifdef _lib_gettimeofday
struct timeval tmp;
gettimeofday(&tmp,NIL(void *));
now = tmp.tv_sec + 1.e-6*tmp.tv_usec;
#else
now = (double)time(NIL(time_t*));
#endif /*_lib_gettimeofday */
nv_putv(np,val,flag,fp);
d = nv_getnum(np);
tp = (struct tevent*)fp;
if(*val=='+')
{
double x = d + now;
nv_putv(np,(char*)&x,NV_INTEGER,fp);
}
else
d -= now;
tp->milli = 1000*(d+.0005);
if(tp->timeout)
sh.st.timetrap = time_delete(tp,sh.st.timetrap);
if(tp->milli > 0)
sh.st.timetrap = time_add(tp,sh.st.timetrap);
}
else
{
tp = (struct tevent*)nv_stack(np, (Namfun_t*)0);
sh.st.timetrap = time_delete(tp,sh.st.timetrap);
if(tp->action)
nv_close(tp->action);
nv_unset(np);
free((__V_*)fp);
}
}
static const Namdisc_t alarmdisc =
{
sizeof(struct tevent),
putval,
0,
0,
setdisc,
};
int b_alarm __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register int n,rflag=0;
register Namval_t *np;
register struct tevent *tp;
NOT_USED(extra);
while (n = optget(argv, sh_optalarm)) switch (n)
{
case 'r':
rflag = R_FLAG;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argc -= opt_index;
argv += opt_index;
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(argc==0)
{
print_alarms(sh.st.timetrap);
return(0);
}
if(argc!=2)
error(ERROR_usage(2),optusage((char*)0));
np = nv_open(argv[0],sh.var_tree,NV_ARRAY|NV_VARNAME|NV_NOASSIGN);
if(!nv_isnull(np))
nv_unset(np);
nv_setattr(np, NV_INTEGER|NV_DOUBLE);
if(!(tp = newof(NIL(struct tevent*),struct tevent,1,0)))
error(ERROR_exit(1),e_nospace);
tp->fun.disc = &alarmdisc;
tp->flags = rflag;
tp->node = np;
nv_stack(np,(Namfun_t*)tp);
nv_putval(np, argv[1], 0);
return(0);
}

View File

@@ -0,0 +1,255 @@
/* $XConsortium: cd_pwd.c /main/3 1995/11/01 16:27:31 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <stak.h>
#include <error.h>
#include "variables.h"
#include "path.h"
#include "name.h"
#include "builtins.h"
#include <ls.h>
int b_cd __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
register char *dir, *cdpath="";
register const char *dp;
int saverrno=0;
int rval,flag = (sh_isoption(SH_PHYSICAL)!=0);
char *oldpwd;
Namval_t *opwdnod, *pwdnod;
NOT_USED(extra);
if(sh_isoption(SH_RESTRICTED))
error(ERROR_exit(1),e_restricted+4);
while((rval = optget(argv,sh_optcd))) switch(rval)
{
case 'L':
flag = 0;
break;
case 'P':
flag = 1;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
argc -= opt_index;
dir = argv[0];
if(error_info.errors>0 || argc >2)
error(ERROR_usage(2),optusage((char*)0));
oldpwd = (char*)sh.pwd;
opwdnod = (sh.subshell?sh_assignok(OLDPWDNOD,1):OLDPWDNOD);
pwdnod = (sh.subshell?sh_assignok(PWDNOD,1):PWDNOD);
if(argc==2)
dir = sh_substitute(oldpwd,dir,argv[1]);
else if(!dir || *dir==0)
dir = nv_getval(HOME);
else if(*dir == '-' && dir[1]==0)
dir = nv_getval(opwdnod);
if(!dir || *dir==0)
error(ERROR_exit(1),argc==2?e_subst+4:e_direct);
if(*dir != '/')
{
cdpath = nv_getval(nv_scoped(CDPNOD));
if(!oldpwd)
oldpwd = path_pwd(1);
}
if(!cdpath)
cdpath = "";
if(*dir=='.')
{
/* test for pathname . ./ .. or ../ */
if(*(dp=dir+1) == '.')
dp++;
if(*dp==0 || *dp=='/')
cdpath = "";
}
rval = -1;
do
{
dp = cdpath;
cdpath=path_join(cdpath,dir);
if(*stakptr(PATH_OFFSET)!='/')
{
char *last=(char*)stakfreeze(1);
stakseek(PATH_OFFSET);
stakputs(oldpwd);
stakputc('/');
stakputs(last+PATH_OFFSET);
stakputc(0);
}
if(!flag)
{
register char *cp;
stakseek(PATH_MAX+PATH_OFFSET);
#ifdef SHOPT_FS_3D
if(!(cp = pathcanon(stakptr(PATH_OFFSET),PATH_DOTDOT)))
continue;
/* eliminate trailing '/' */
while(*--cp == '/' && cp>stakptr(PATH_OFFSET))
*cp = 0;
#else
if(*(cp=stakptr(PATH_OFFSET))=='/')
if(!pathcanon(cp,PATH_DOTDOT))
continue;
#endif /* SHOPT_FS_3D */
}
if((rval=chdir(path_relative(stakptr(PATH_OFFSET)))) >= 0)
goto success;
if(errno!=ENOENT && saverrno==0)
saverrno=errno;
}
while(cdpath);
if(rval<0 && *dir=='/' && *(path_relative(stakptr(PATH_OFFSET)))!='/')
rval = chdir(dir);
/* use absolute chdir() if relative chdir() fails */
if(rval<0)
{
if(saverrno)
errno = saverrno;
error(ERROR_system(1),"%s:",dir);
}
success:
if(dir == nv_getval(opwdnod) || argc==2)
dp = dir; /* print out directory for cd - */
if(flag)
{
dir = stakptr(PATH_OFFSET);
if (!(dir=pathcanon(dir,PATH_PHYSICAL)))
{
dir = stakptr(PATH_OFFSET);
error(ERROR_system(1),"%s:",dir);
}
stakseek(dir-stakptr(0));
}
dir = (char*)stakfreeze(1)+PATH_OFFSET;
if(*dp && *dp!= ':' && strchr(dir,'/'))
sfputr(sfstdout,dir,'\n');
if(*dir != '/')
return(0);
nv_putval(opwdnod,oldpwd,NV_RDONLY);
if(oldpwd)
free(oldpwd);
flag = strlen(dir);
/* delete trailing '/' */
while(--flag>0 && dir[flag]=='/')
dir[flag] = 0;
nv_putval(pwdnod,dir,NV_RDONLY);
nv_onattr(pwdnod,NV_NOFREE|NV_EXPORT);
sh.pwd = pwdnod->nvalue.cp;
return(0);
}
int b_pwd __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
register int n, flag = (sh_isoption(SH_PHYSICAL)!=0);
register char *cp;
NOT_USED(extra);
NOT_USED(argc);
while((n = optget(argv,sh_optpwd))) switch(n)
{
case 'L':
flag = 0;
break;
case 'P':
flag = 1;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(*(cp = path_pwd(0)) != '/')
error(ERROR_system(1), e_pwd);
if(flag)
{
#ifdef SHOPT_FS_3D
if((flag = mount(e_dot,NIL(char*),FS3D_GET|FS3D_VIEW,0))>=0)
{
cp = (char*)stakseek(++flag+PATH_MAX);
mount(e_dot,cp,FS3D_GET|FS3D_VIEW|FS3D_SIZE(flag),0);
}
else
#endif /* SHOPT_FS_3D */
cp = strcpy(stakseek(strlen(cp)+PATH_MAX),cp);
pathcanon(cp,PATH_PHYSICAL);
}
sfputr(sfstdout,cp,'\n');
return(0);
}

View File

@@ -0,0 +1,147 @@
/* $XConsortium: cflow.c /main/3 1995/11/01 16:27:48 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <ast.h>
#include <error.h>
#include <ctype.h>
#include "shnodes.h"
#include "builtins.h"
/*
* return and exit
*/
int b_ret_exit __PARAM__((register int n, register char *argv[],__V_ *extra), (n, argv, extra)) __OTORP__(register int n; register char *argv[];__V_ *extra;){
struct checkpt *pp = (struct checkpt*)sh.jmplist;
register char *arg;
NOT_USED(extra);
while((n = optget(argv,sh_optcflow))) switch(n)
{
case ':':
if(!strmatch(argv[opt_index],"[+-]+([0-9])"))
error(2, opt_arg);
goto done;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
done:
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
pp->mode = (**argv=='e'?SH_JMPEXIT:SH_JMPFUN);
argv += opt_index;
n = (((arg= *argv)?atoi(arg):sh.oldexit)&SH_EXITMASK);
/* return outside of function, dotscript and profile is exit */
if(sh.fn_depth==0 && sh.dot_depth==0 && !sh_isstate(SH_PROFILE))
pp->mode = SH_JMPEXIT;
sh_exit(n);
return(1);
}
/*
* break and continue
*/
int b_brk_cont __PARAM__((register int n, register char *argv[],__V_ *extra), (n, argv, extra)) __OTORP__(register int n; register char *argv[];__V_ *extra;){
char *arg;
register int cont= **argv=='c';
NOT_USED(extra);
while((n = optget(argv,sh_optcflow))) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
n=1;
if(arg= *argv)
{
n = strtol(arg,&arg,10);
if(n<=0 || *arg)
error(ERROR_exit(1),e_nolabels,*argv);
}
if(sh.st.loopcnt)
{
sh.st.execbrk = sh.st.breakcnt = n;
if(sh.st.breakcnt > sh.st.loopcnt)
sh.st.breakcnt = sh.st.loopcnt;
if(cont)
sh.st.breakcnt = -sh.st.breakcnt;
}
return(0);
}

View File

@@ -0,0 +1,175 @@
/* $XConsortium: getconf.c /main/3 1995/11/01 16:28:05 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <shell.h>
#include <ast.h>
#include <stak.h>
#include <error.h>
#include "shtable.h"
#include "builtins.h"
#include "FEATURE/externs"
#define next_config(p) ((Shtable_t*)((char*)(p) + sizeof(*shtab_config)))
#define MIN_LEN 20
int b_getconf __PARAM__((register int argc, char *argv[]), (argc, argv)) __OTORP__(register int argc; char *argv[];){
register int m,n;
register long val;
register const char *name, *path="";
int offset = staktell();
const Shtable_t *tp = shtab_config;
error_info.id = argv[0];
while (n = optget(argv, sh_optgetconf)) switch (n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
argc -= opt_index;
if(argc >2)
error(ERROR_usage(2),optusage((char*)0));
while(1)
{
if(argc)
{
name = *argv;
n = sh_lookup(name,shtab_config);
}
else
{
name = tp->sh_name;
n = tp->sh_number;
if(*name==0)
break;
}
m = n>>2;
errno = 0;
val = -1;
switch(n&03)
{
case 0:
if(m==0)
errno = EINVAL;
break;
case 1:
#ifdef _lib_confstr
stakseek(offset+MIN_LEN);
if((n=confstr(m,stakptr(offset),MIN_LEN)) > MIN_LEN)
{
stakseek(offset+n);
confstr(m,stakptr(offset),n);
}
#else
if(strcmp(name,"PATH"))
errno = EINVAL;
else
stakputs(e_defpath);
#endif /* _lib_confstr */
val = 0;
break;
case 2:
val = sysconf(m);
break;
case 3:
if(argc==0)
path = "/";
else if(argc!=2)
error(ERROR_exit(1),e_needspath,name);
else
path=argv[1];
val = pathconf(path,m);
break;
}
if(errno)
error(ERROR_system(0),e_badconf,name,path);
path= "";
if(argc==0)
sfputr(sfstdout,name,'=');
if(val==-1)
sfputr(sfstdout,"undefined",'\n');
else if((n&03)==1)
sfputr(sfstdout,stakptr(offset),'\n');
else
sfprintf(sfstdout,"%ld\n",val);
if(argc)
break;
tp= next_config(tp);
val = -1;
}
stakseek(offset);
return(error_info.errors);
}

View File

@@ -0,0 +1,181 @@
/* $XConsortium: getopts.c /main/3 1995/11/01 16:28:23 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#ifdef __osf__
#include <machine/machlimits.h>
#endif
#include "defs.h"
#include "variables.h"
#include <error.h>
#include <nval.h>
#include "builtins.h"
int b_getopts __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register char *options=error_info.context->id;
register Namval_t *np;
register int flag, mode, r=0;
static char value[2], key[2];
NOT_USED(extra);
while((flag = optget(argv,sh_optgetopts))) switch(flag)
{
case 'a':
options = opt_arg;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
argc -= opt_index;
if(error_info.errors || argc<2)
error(ERROR_usage(2),optusage((char*)0));
error_info.context->flags |= ERROR_SILENT;
error_info.id = options;
options = argv[0];
np = nv_open(argv[1],sh.var_tree,NV_NOASSIGN|NV_VARNAME);
if(argc>2)
{
argv +=1;
argc -=1;
}
else
{
argv = sh.st.dolv;
argc = sh.st.dolc;
}
opt_index = sh.st.optindex;
opt_char = sh.st.optchar;
if(mode= (*options==':'))
options++;
switch(opt_index<=argc?(opt_num= LONG_MIN,flag=optget(argv,options)):0)
{
case '?':
error(ERROR_usage(0),opt_arg);
r = 2;
*(options = value) = flag;
break;
case ':':
key[0] = opt_option[1];
if(strmatch(opt_arg,"*unknown*"))
flag = '?';
if(mode)
opt_arg = key;
else
{
error(2, opt_arg);
opt_arg = 0;
flag = '?';
}
*(options = value) = flag;
sh.st.opterror = 1;
break;
case 0:
if(sh.st.opterror)
{
char *com[2];
com[0] = "-?";
com[1] = 0;
flag = opt_index;
opt_index = 0;
optget(com,options);
opt_index = flag;
if(!mode && strchr(options,' '))
error(ERROR_usage(0),optusage((char*)0));
}
opt_arg = 0;
options = value;
*options = '?';
r=1;
opt_char = 0;
break;
default:
options = opt_option + (*opt_option!='+');
}
error_info.context->flags &= ~ERROR_SILENT;
sh.st.optindex = opt_index;
sh.st.optchar = opt_char;
nv_putval(np, options, 0);
nv_close(np);
np = nv_search((char*)OPTARGNOD,sh.var_tree,NV_ADD|HASH_BUCKET|HASH_NOSCOPE);
if(opt_num != LONG_MIN)
{
double d = opt_num;
nv_putval(np, (char*)&d, NV_INTEGER|NV_RDONLY);
}
else
nv_putval(np, opt_arg, NV_RDONLY);
return(r);
}

View File

@@ -0,0 +1,322 @@
/* $XConsortium: hist.c /main/3 1995/11/01 16:28:36 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <stak.h>
#include <ls.h>
#include <error.h>
#include <ctype.h>
#include "variables.h"
#include "io.h"
#include "name.h"
#include "history.h"
#include "builtins.h"
static void hist_subst __PROTO__((const char*, int fd, char*));
int b_hist __PARAM__((int argc,char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[]; __V_ *extra;){
register History_t *hp;
register char *arg;
register int flag,fdo;
struct stat statb;
time_t before;
Sfio_t *outfile;
char *fname;
int range[2], incr, index2, indx= -1;
char *edit = 0; /* name of editor */
char *replace = 0; /* replace old=new */
int lflag = 0, nflag = 0, rflag = 0;
Histloc_t location;
NOT_USED(argc);
NOT_USED(extra);
if(!sh_histinit())
error(ERROR_system(1),e_histopen);
hp = sh.hist_ptr;
while((flag = optget(argv,sh_opthist))) switch(flag)
{
case 'e':
edit = opt_arg;
break;
case 'n':
nflag++;
break;
case 'l':
lflag++;
break;
case 'r':
rflag++;
break;
case 's':
edit = "-";
break;
case 'N':
if(indx<=0)
{
if((flag = hist_max(hp) - opt_num-1) < 0)
flag = 1;
range[++indx] = flag;
break;
}
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += (opt_index-1);
flag = indx;
while(flag<1 && (arg=argv[1]))
{
/* look for old=new argument */
if(!replace && strchr(arg+1,'='))
{
replace = arg;
argv++;
continue;
}
else if(isdigit(*arg) || *arg == '-')
{
/* see if completely numeric */
do arg++;
while(isdigit(*arg));
if(*arg==0)
{
arg = argv[1];
range[++flag] = atoi(arg);
if(*arg == '-')
range[flag] += (hist_max(hp)-1);
argv++;
continue;
}
}
/* search for last line starting with string */
location = hist_find(hp,argv[1],hist_max(hp)-1,0,-1);
if((range[++flag] = location.hist_command) < 0)
error(ERROR_exit(1),e_found,argv[1]);
argv++;
}
if(flag <0)
{
/* set default starting range */
if(lflag)
{
flag = hist_max(hp)-17;
if(flag<1)
flag = 1;
}
else
flag = hist_max(hp)-2;
range[0] = flag;
flag = 0;
}
index2 = hist_min(hp);
if(range[0]<index2)
range[0] = index2;
if(flag==0)
/* set default termination range */
range[1] = (lflag?hist_max(hp)-2:range[0]);
if(range[1]>=(flag=(hist_max(hp) - 1)))
range[1] = flag;
/* check for valid ranges */
if(range[1]<index2 || range[0]>=flag)
error(ERROR_exit(1),e_badrange,range[0],range[1]);
if(edit && *edit=='-' && range[0]!=range[1])
error(ERROR_exit(1),e_eneedsarg);
/* now list commands from range[rflag] to range[1-rflag] */
incr = 1;
flag = rflag>0;
if(range[1-flag] < range[flag])
incr = -1;
if(lflag)
{
outfile = sfstdout;
arg = "\n\t";
}
else
{
if(!(fname=pathtemp(NIL(char*),0,0)))
error(ERROR_exit(1),e_create,"");
if((fdo=open(fname,O_CREAT|O_RDWR,S_IRUSR|S_IWUSR)) < 0)
error(ERROR_system(1),e_create,fname);
outfile= sfnew(NIL(Sfio_t*),sh.outbuff,IOBSIZE,fdo,SF_WRITE);
arg = "\n";
nflag++;
}
while(1)
{
if(nflag==0)
sfprintf(outfile,"%d\t",range[flag]);
else if(lflag)
sfputc(outfile,'\t');
hist_list(sh.hist_ptr,outfile,hist_tell(sh.hist_ptr,range[flag]),0,arg);
if(lflag)
sh_sigcheck();
if(range[flag] == range[1-flag])
break;
range[flag] += incr;
}
if(lflag)
return(0);
if(fstat(sffileno(outfile),&statb)>=0)
before = statb.st_mtime;
sfclose(outfile);
hist_eof(hp);
arg = edit;
if(!arg && !(arg=nv_getval(nv_scoped(HISTEDIT))) && !(arg=nv_getval(nv_scoped(FCEDNOD))))
arg = (char*)e_defedit;
#ifdef apollo
/*
* Code to support the FC using the pad editor.
* Exampled of how to use: HISTEDIT=pad
*/
if (strcmp (arg, "pad") == 0)
{
extern __MANGLE__ int pad_create __PROTO__((char*));
sh_close(fdo);
fdo = pad_create(fname);
pad_wait(fdo);
unlink(fname);
strcat(fname, ".bak");
unlink(fname);
lseek(fdo,(off_t)0,SEEK_SET);
}
else
{
#endif /* apollo */
if(*arg != '-')
{
char *com[3];
com[0] = arg;
com[1] = fname;
com[2] = 0;
error_info.errors = sh_eval(sh_sfeval(com),0);
}
fdo = sh_chkopen(fname);
unlink(fname);
free((__V_*)fname);
#ifdef apollo
}
#endif /* apollo */
/* don't history fc itself unless forked */
error_info.flags |= ERROR_SILENT;
if(!sh_isstate(SH_FORKED))
hist_cancel(hp);
sh_onstate(SH_VERBOSE|SH_HISTORY); /* echo lines as read */
if(replace)
hist_subst(error_info.id,fdo,replace);
else if(error_info.errors == 0)
{
char buff[IOBSIZE+1];
Sfio_t *iop = sfnew(NIL(Sfio_t*),buff,IOBSIZE,fdo,SF_READ);
/* read in and run the command */
sh_eval(iop,1);
}
else
{
sh_close(fdo);
if(!sh_isoption(SH_VERBOSE))
sh_offstate(SH_VERBOSE|SH_HISTORY);
}
return(sh.exitval);
}
/*
* given a file containing a command and a string of the form old=new,
* execute the command with the string old replaced by new
*/
static void hist_subst __PARAM__((const char *command,int fd,char *replace), (command, fd, replace)) __OTORP__(const char *command;int fd;char *replace;){
register char *newp=replace;
register char *sp;
register int c;
off_t size;
char *string;
while(*++newp != '='); /* skip to '=' */
if((size = lseek(fd,(off_t)0,SEEK_END)) < 0)
return;
lseek(fd,(off_t)0,SEEK_SET);
c = (int)size;
string = stakalloc(c+1);
if(read(fd,string,c)!=c)
return;
string[c] = 0;
*newp++ = 0;
if((sp=sh_substitute(string,replace,newp))==0)
error(ERROR_exit(1),e_subst,command);
*(newp-1) = '=';
sh_eval(sfopen(NIL(Sfio_t*),sp,"s"),1);
}

View File

@@ -0,0 +1,539 @@
/* $XConsortium: misc.c /main/3 1995/11/01 16:28:50 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include "variables.h"
#include "shnodes.h"
#include "path.h"
#include "io.h"
#include "name.h"
#include "history.h"
#include "builtins.h"
#include "jobs.h"
#define DOTMAX 32 /* maximum level of . nesting */
static int clear;
static void noexport __PROTO__((Namval_t*));
static char *arg0;
int b_exec __PARAM__((int argc,char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[]; __V_ *extra;){
register int n;
sh.st.ioset = 0;
clear = 0;
NOT_USED(extra);
while (n = optget(argv, sh_optexec)) switch (n)
{
case 'a':
arg0 = opt_arg;
argc = 0;
break;
case 'c':
clear=1;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
argv += opt_index;
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(*argv)
b_login(argc,argv,0);
return(0);
}
static void noexport __PARAM__((register Namval_t* np), (np)) __OTORP__(register Namval_t* np;){
nv_offattr(np,NV_EXPORT);
}
int b_login __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
const char *pname;
struct checkpt *pp = (struct checkpt*)sh.jmplist;
NOT_USED(extra);
if(sh_isoption(SH_RESTRICTED))
error(ERROR_exit(1),e_restricted,argv[0]);
else
{
register struct argnod *arg=sh.envlist;
register Namval_t* np;
register char *cp;
if(sh.subshell)
sh_subfork();
if(clear)
nv_scan(sh.var_tree,noexport,NV_EXPORT,NV_EXPORT);
while(arg)
{
if((cp=strchr(arg->argval,'=')) &&
(*cp=0,np=nv_search(arg->argval,sh.var_tree,0)))
nv_onattr(np,NV_EXPORT);
if(cp)
*cp = '=';
arg=arg->argnxt.ap;
}
pname = argv[0];
if(argc==0)
argv[0] = arg0;
#ifdef JOBS
if(job_close() < 0)
return(1);
#endif /* JOBS */
/* force bad exec to terminate shell */
pp->mode = SH_JMPEXIT;
sh_sigreset(2);
sh_freeup();
path_exec(pname,argv,NIL(struct argnod*));
sh_done(0);
}
return(1);
}
int b_let __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register int r;
register char *arg;
NOT_USED(argc);
NOT_USED(extra);
while (r = optget(argv,sh_optlet)) switch (r)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors || !*argv)
error(ERROR_usage(2),optusage((char*)0));
while(arg= *argv++)
r = !sh_arith(arg);
return(r);
}
int b_eval __PARAM__((int argc,char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[]; __V_ *extra;){
register int r;
NOT_USED(argc);
NOT_USED(extra);
while (r = optget(argv,sh_opteval)) switch (r)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
if(*argv && **argv)
{
sh_offstate(SH_MONITOR);
sh_eval(sh_sfeval(argv),0);
}
return(sh.exitval);
}
int b_dot_cmd __PARAM__((register int n,char *argv[],__V_* extra), (n, argv, extra)) __OTORP__(register int n;char *argv[];__V_* extra;){
register char *script;
register Namval_t *np;
register int jmpval;
int fd;
struct dolnod *argsave=0, *saveargfor;
char **saveargv;
struct checkpt buff;
Sfio_t *iop=0;
NOT_USED(extra);
while (n = optget(argv,sh_optdot)) switch (n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
argv += opt_index;
script = *argv;
if(error_info.errors || !script)
error(ERROR_usage(2),optusage((char*)0));
if(!(np=sh.posix_fun))
{
/* check for KornShell style function first */
np = nv_search(script,sh.fun_tree,0);
if(np && is_afunction(np) && !nv_isattr(np,NV_FPOSIX))
{
if(!np->nvalue.ip)
{
path_search(script,NIL(char*),0);
if(np->nvalue.ip)
{
if(nv_isattr(np,NV_FPOSIX))
np = 0;
}
else
error(ERROR_exit(1),e_found,script);
}
}
else
np = 0;
if(!np && (fd=path_open(script,path_get(script))) < 0)
error(ERROR_system(1),e_open,script);
}
sh.posix_fun = 0;
if(sh.dot_depth++ > DOTMAX)
error(ERROR_exit(1),e_toodeep,script);
if(np || argv[1])
{
n = sh.st.dolc;
saveargv = sh.st.dolv;
argsave = sh_argnew(argv,&saveargfor);
}
sh_pushcontext(&buff,SH_JMPDOT);
jmpval = sigsetjmp(buff.buff,0);
if(jmpval == 0)
{
if(np)
sh_exec((union anynode*)(nv_funtree(np)),sh_isstate(SH_ERREXIT));
else
{
char buff[IOBSIZE+1];
iop = sfnew(NIL(Sfio_t*),buff,IOBSIZE,fd,SF_READ);
sh_eval(iop,0);
}
}
sh_popcontext(&buff);
sh.dot_depth--;
if((np || argv[1]) && jmpval!=SH_JMPSCRIPT)
{
sh_argreset(argsave,saveargfor);
sh.st.dolc = n;
sh.st.dolv = saveargv;
}
if(sh.exitval > SH_EXITSIG)
sh_fault(sh.exitval&SH_EXITMASK);
if(jmpval && jmpval!=SH_JMPFUN)
siglongjmp(*sh.jmplist,jmpval);
return(sh.exitval);
}
/*
* null, true command
*/
int b_true __PARAM__((int argc,register char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;register char *argv[];__V_ *extra;){
NOT_USED(argc);
NOT_USED(argv[0]);
NOT_USED(extra);
return(0);
}
/*
* false command
*/
int b_false __PARAM__((int argc,register char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc;register char *argv[]; __V_ *extra;){
NOT_USED(argc);
NOT_USED(argv[0]);
NOT_USED(extra);
return(1);
}
int b_shift __PARAM__((register int n, register char *argv[], __V_ *extra), (n, argv, extra)) __OTORP__(register int n; register char *argv[]; __V_ *extra;){
register char *arg;
NOT_USED(extra);
while((n = optget(argv,sh_optcflow))) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(0), opt_arg);
return(2);
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
n = ((arg= *argv)?(int)sh_arith(arg):1);
if(n<0 || sh.st.dolc<n)
error(ERROR_exit(1),e_number,arg);
else
{
sh.st.dolv += n;
sh.st.dolc -= n;
}
return(0);
}
int b_wait __PARAM__((register int n,register char *argv[],__V_ *extra), (n, argv, extra)) __OTORP__(register int n;register char *argv[];__V_ *extra;){
NOT_USED(extra);
while((n = optget(argv,sh_optjoblist))) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
job_bwait(argv);
return(sh.exitval);
}
#ifdef JOBS
int b_bg_fg __PARAM__((register int n,register char *argv[],__V_ *extra), (n, argv, extra)) __OTORP__(register int n;register char *argv[];__V_ *extra;){
register int flag = **argv;
NOT_USED(extra);
while((n = optget(argv,sh_optjoblist))) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
if(!sh_isoption(SH_MONITOR) || !job.jobcontrol)
{
if(sh_isstate(SH_INTERACTIVE))
error(ERROR_exit(1),e_no_jctl);
return(1);
}
if(flag=='d' && *argv==0)
argv = (char**)0;
if(job_walk(sfstdout,job_switch,flag,argv))
error(ERROR_exit(1),e_no_job);
return(sh.exitval);
}
int b_jobs __PARAM__((register int n,char *argv[],__V_ *extra), (n, argv, extra)) __OTORP__(register int n;char *argv[];__V_ *extra;){
register int flag = 0;
NOT_USED(extra);
while((n = optget(argv,sh_optjobs))) switch(n)
{
case 'l':
flag = JOB_LFLAG;
break;
case 'n':
flag = JOB_NFLAG;
break;
case 'p':
flag = JOB_PFLAG;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(*argv==0)
argv = (char**)0;
if(job_walk(sfstdout,job_list,flag,argv))
error(ERROR_exit(1),e_no_job);
job_wait((pid_t)0);
return(sh.exitval);
}
#endif
#ifdef _cmd_universe
/*
* There are several universe styles that are masked by the getuniv(),
* setuniv() calls.
*/
int b_universe __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
register char *arg;
register int n;
NOT_USED(extra);
while((n = optget(argv,sh_optuniverse))) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
argc -= opt_index;
if(error_info.errors || argc>1)
error(ERROR_usage(2),optusage((char*)0));
if(arg = argv[0])
{
if(!astconf("_AST_UNIVERSE",0,arg))
error(ERROR_exit(1), e_badname,arg);
}
else
{
if(!(arg=astconf("_AST_UNIVERSE",0,0)))
error(ERROR_exit(1),e_nouniverse);
else
sfputr(sfstdout,arg,'\n');
}
return(0);
}
#endif /* cmd_universe */
#ifdef SHOPT_FS_3D
int b_vpath_map __PARAM__((register int argc,char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(register int argc;char *argv[]; __V_ *extra;){
register int flag, n;
register const char *optstr;
register char *vend;
NOT_USED(extra);
if(argv[0][1]=='p')
{
optstr = sh_optvpath;
flag = FS3D_VIEW;
}
else
{
optstr = sh_optvmap;
flag = FS3D_VERSION;
}
while(n = optget(argv, optstr)) switch(n)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
argc -= opt_index;
switch(argc)
{
case 0:
case 1:
flag |= FS3D_GET;
if((n = mount(*argv,(char*)0,flag,0)) >= 0)
{
vend = stakalloc(++n);
n = mount(*argv,vend,flag|FS3D_SIZE(n),0);
}
if(n < 0)
goto failed;
if(argc==1)
{
sfprintf(sfstdout,"%s\n",vend);
break;
}
n = 0;
while(flag = *vend++)
{
if(flag==' ')
{
flag = e_sptbnl[n+1];
n = !n;
}
sfputc(sfstdout,flag);
}
if(n)
sfputc(sfstdout,'\n');
break;
default:
if((argc&1))
error(ERROR_usage(2),optusage((char*)0));
/*FALLTHROUGH*/
case 2:
if(!sh.lim.fs3d)
goto failed;
if(sh.subshell)
sh_subfork();
for(n=0;n<argc;n+=2)
{
if(mount(argv[n+1],argv[n],flag,0)<0)
goto failed;
}
}
return(0);
failed:
if(argc>1)
error(ERROR_exit(1),e_cantset,flag==2?e_mapping:e_versions);
else
error(ERROR_exit(1),e_cantget,flag==2?e_mapping:e_versions);
return(1);
}
#endif /* SHOPT_FS_3D */

View File

@@ -0,0 +1,610 @@
/* $XConsortium: print.c /main/3 1995/11/01 16:29:05 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <error.h>
#include <stak.h>
#include "io.h"
#include "name.h"
#include "history.h"
#include "builtins.h"
union types_t
{
unsigned char c;
int i;
long l;
double d;
float f;
char *s;
int *ip;
char **p;
};
static int getarg __PROTO__((int, union types_t *));
static int extend __PROTO__((char*, int, int, char**));
static char *genformat __PROTO__((char*));
static int fmtvecho __PROTO__((const char*));
#define fmtre(x) (x)
static char bsd_univ,cescape, raw, echon;
static char **nextarg;
static const char *options;
static const char preformat[] = "%&%@";
/*
* Need to handle write failures to avoid locking output pool
*/
static int outexceptf __PARAM__((Sfio_t* iop, int mode, Sfdisc_t* dp), (iop, mode, dp)) __OTORP__(Sfio_t* iop; int mode; Sfdisc_t* dp;){
if(mode==SF_DPOP || mode==SF_CLOSE)
free((__V_*)dp);
else if(mode==SF_WRITE)
{
int save = errno;
sfpurge(iop);
sfpool(iop,NIL(Sfio_t*),SF_WRITE);
errno = save;
error(ERROR_system(1),e_badwrite,sffileno(iop));
}
return(0);
}
#ifndef SHOPT_ECHOPRINT
int b_echo __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
options = sh_optecho+5;
raw = echon = 0;
NOT_USED(argc);
NOT_USED(extra);
/* This mess is because /bin/echo on BSD is different */
if(!sh.universe)
{
register char *universe;
if(universe=astconf("_AST_UNIVERSE",0,0))
bsd_univ = (strcmp(universe,"ucb")==0);
sh.universe = 1;
}
if(!bsd_univ)
return(b_print(0,argv,0));
options = sh_optecho;
raw = 1;
if(argv[1] && strcmp(argv[1],"-n")==0)
echon = 1;
return(b_print(0,argv+echon,0));
}
#endif /* SHOPT_ECHOPRINT */
int b_printf __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
NOT_USED(argc);
NOT_USED(extra);
options = sh_optprintf;
return(b_print(-1,argv,0));
}
/*
* argc==0 when called from echo
* argc==-1 when called from printf
*/
int b_print __PARAM__((int argc, char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[]; __V_ *extra;){
register Sfio_t *outfile;
register int n, fd = 1;
const char *msg = e_file+4;
char *format = 0;
int sflag = 0, nflag, rflag;
NOT_USED(extra);
if(argc>0)
{
options = sh_optprint;
nflag = rflag = 0;
format = 0;
}
else if(argc==0)
{
nflag = echon;
rflag = raw;
argv++;
goto skip;
}
while((n = optget(argv,options))) switch(n)
{
case 'n':
nflag++;
break;
case 'p':
fd = sh.coutpipe;
msg = e_query;
break;
case 'f':
format = opt_arg;
break;
case 's':
/* print to history file */
if(!sh_histinit())
error(ERROR_system(1),e_history);
fd = sffileno(sh.hist_ptr->histfp);
sh_onstate(SH_HISTORY);
sflag++;
break;
case 'e':
rflag = 0;
break;
case 'r':
rflag = 1;
break;
case 'u':
fd = (int)strtol(opt_arg,&opt_arg,10);
if(*opt_arg)
fd = -1;
else if(fd<0 || fd >= sh.lim.open_max)
fd = -1;
else if(sh_inuse(fd) || (sh.hist_ptr && fd==sffileno(sh.hist_ptr->histfp)))
fd = -1;
break;
case ':':
/* The followin is for backward compatibility */
if(strcmp(opt_option,"-R")==0)
{
rflag = 1;
if(error_info.errors==0)
{
argv += opt_index+1;
/* special case test for -Rn */
if(strchr(argv[-1],'n'))
nflag++;
if(*argv && strcmp(*argv,"-n")==0)
{
nflag++;
argv++;
}
goto skip2;
}
}
else
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors || (argc<0 && !(format = *argv++)))
error(ERROR_usage(2),optusage((char*)0));
skip:
if(format)
format = genformat(format);
/* handle special case of '-' operand for print */
if(argc>0 && *argv && strcmp(*argv,"-")==0 && strcmp(argv[-1],"--"))
argv++;
skip2:
if(fd < 0)
{
errno = EBADF;
n = 0;
}
else if(!(n=sh.fdstatus[fd]))
n = sh_iocheckfd(fd);
#ifndef __osf__
if(!(n&IOWRITE))
{
/* don't print error message for stdout for compatibility */
if(fd==1)
return(1);
error(ERROR_system(1),msg);
}
#endif
if(!(outfile=sh.sftable[fd]))
{
Sfdisc_t *dp;
sh_onstate(SH_NOTRACK);
n = SF_WRITE|((n&IOREAD)?SF_READ:0);
sh.sftable[fd] = outfile = sfnew(NIL(Sfio_t*),sh.outbuff,IOBSIZE,fd,n);
sh_offstate(SH_NOTRACK);
sfpool(outfile,sh.outpool,SF_WRITE);
if(dp = new_of(Sfdisc_t,0))
{
dp->exceptf = outexceptf;
dp->seekf = 0;
dp->writef = 0;
dp->readf = 0;
sfdisc(outfile,dp);
}
}
cescape = 0;
/* turn off share to guarantee atomic writes for printf */
n = sfset(outfile,SF_SHARE|SF_PUBLIC,0);
if(format)
{
/* printf style print */
Sfio_t *pool;
sh_offstate(SH_STOPOK);
pool=sfpool(sfstderr,NIL(Sfio_t*),SF_WRITE);
nextarg = argv;
do
{
if(sh.trapnote&SH_SIGSET)
break;
sfprintf(outfile,format,extend,getarg);
}
while(*nextarg && nextarg!=argv);
sfpool(sfstderr,pool,SF_WRITE);
}
else
{
/* echo style print */
if(sh_echolist(outfile,rflag,argv) && !nflag)
sfputc(outfile,'\n');
}
if(sflag)
{
hist_flush(sh.hist_ptr);
sh_offstate(SH_HISTORY);
}
else if(n&SF_SHARE)
{
sfset(outfile,SF_SHARE|SF_PUBLIC,1);
sfsync(outfile);
}
return(0);
}
/*
* echo the argument list onto <outfile>
* if <raw> is non-zero then \ is not a special character.
* returns 0 for \c otherwise 1.
*/
int sh_echolist __PARAM__((Sfio_t *outfile, int raw, char *argv[]), (outfile, raw, argv)) __OTORP__(Sfio_t *outfile; int raw; char *argv[];){
register char *cp;
register int n;
while(!cescape && (cp= *argv++))
{
if(!raw && (n=fmtvecho(cp))>=0)
{
if(n)
sfwrite(outfile,stakptr(staktell()),n);
}
else
sfputr(outfile,cp,-1);
if(*argv)
sfputc(outfile,' ');
sh_sigcheck();
}
return(!cescape);
}
static char *genformat __PARAM__((char *format), (format)) __OTORP__(char *format;){
register char *fp;
stakseek(0);
stakputs(preformat);
stakputs(format);
fp = (char*)stakfreeze(1);
stresc(fp+sizeof(preformat)-1);
return(fp);
}
static int getarg __PARAM__((int format,union types_t *value), (format, value)) __OTORP__(int format;union types_t *value;){
register char *argp = *nextarg;
char *lastchar = "";
register int neg = 0;
if(!argp)
{
switch(format)
{
case 'c':
value->c = 0;
break;
case 's':
case 'q':
case 'P':
case 'R':
case 'b':
value->s = "";
break;
case 'f':
value->f = 0.;
break;
case 'F':
value->d = 0.;
break;
case 'n':
{
static int intvar;
value->ip = &intvar;
break;
}
default:
value->l = 0;
}
return(0);
}
switch(format)
{
case 'p':
value->p = (char**)strtol(argp,&lastchar,10);
break;
case 'n':
{
Namval_t *np;
np = nv_open(argp,sh.var_tree,NV_VARNAME|NV_NOASSIGN|NV_ARRAY);
nv_unset(np);
nv_onattr(np,NV_INTEGER);
np->nvalue.lp = new_of(long,0);
nv_setsize(np,10);
if(sizeof(int)==sizeof(long))
value->ip = (int*)np->nvalue.lp;
else
{
struct temp { int hi; int low; } *sp = (struct temp*)(np->nvalue.lp);
sp->hi = 0;
sp->low = 1;
if(*np->nvalue.lp==1)
value->ip = &sp->low;
else
value->ip = &sp->hi;
}
nv_close(np);
break;
}
case 'q':
case 'b':
case 's':
case 'P':
case 'R':
value->s = argp;
break;
case 'c':
value->c = *argp;
break;
case 'u':
case 'U':
case 'd':
case 'D':
switch(*argp)
{
case '\'': case '"':
value->l = argp[1];
break;
default:
value->l = (long)sh_strnum(argp,&lastchar);
if(lastchar == *nextarg)
{
value->l = *argp;
lastchar = "";
}
}
if(neg)
value->l = -value->l;
if(sizeof(int)!=sizeof(long) && format=='d')
value->i = (int)value->l;
break;
case 'f':
case 'F':
value->d = sh_strnum(*nextarg,&lastchar);
if(sizeof(float)!=sizeof(double) && format=='f')
value->f = (float)value->d;
break;
default:
value->l = 0;
error(ERROR_exit(1),e_formspec,format);
}
if(*lastchar)
error(ERROR_exit(1),e_argtype,format);
nextarg++;
return(0);
}
/*
* This routine adds new % escape sequences to printf
*/
static int extend __PARAM__((char *invalue,int format,int precis,char **outval), (invalue, format, precis, outval)) __OTORP__(char *invalue;int format;int precis;char **outval;){
register int n;
NOT_USED(precis);
switch(format)
{
case 'b':
if((n=fmtvecho(invalue))>=0)
{
*outval = stakptr(staktell());
return(n);
}
*outval = invalue;
return(strlen(*outval));
case 'q':
*outval = sh_fmtq(invalue);
return(strlen(*outval));
case 'P':
*outval = fmtmatch(invalue);
if(*outval==0)
error(ERROR_exit(1),e_badregexp,invalue);
return(strlen(*outval));
case 'R':
*outval = fmtre(invalue);
if(*outval==0)
error(ERROR_exit(1),e_badregexp,invalue);
return(strlen(*outval));
default:
*outval = 0;
return(-1);
}
}
/*
* construct System V echo string out of <cp>
* If there are not escape sequences, returns -1
* Otherwise, puts null terminated result on stack, but doesn't freeze it
* returns lenght of output.
*/
static int fmtvecho __PARAM__((const char *string), (string)) __OTORP__(const char *string;){
static char *nullarg;
register const char *cp = string, *cpmax;
register int c;
register int offset = staktell();
int chlen;
if (MB_CUR_MAX > 1)
{
while (1)
{
if ((chlen = mblen(cp, MB_CUR_MAX)) > 1)
{
/* Skip over multibyte characters */
cp += chlen;
}
else
{
c = *cp++;
if ((c == '\0') || (c == '\\'))
break;
}
}
}
else
while((c= *cp++) && (c!='\\'));
if(c==0)
return(-1);
c = --cp - string;
if(c>0)
stakwrite((__V_*)string,c);
/* for(; c= *cp; cp++) */
while(1)
{
if ((MB_CUR_MAX > 1) && ((chlen = mblen(cp, MB_CUR_MAX)) > 1))
{
/* Skip over multibyte characters */
int i;
for (i = 0; i < chlen; i++)
{
c = *cp++;
stakputc(c);
}
}
else
{
if ((c = *cp) == '\0')
break;
if( c=='\\') switch(*++cp)
{
case 'E':
c = '\033';
break;
case 'a':
c = '\007';
break;
case 'b':
c = '\b';
break;
case 'c':
cescape++;
nextarg = &nullarg;
goto done;
case 'f':
c = '\f';
break;
case 'n':
c = '\n';
break;
case 'r':
c = '\r';
break;
case 'v':
c = '\013';
break;
case 't':
c = '\t';
break;
case '\\':
c = '\\';
break;
case '0':
c = 0;
cpmax = cp + 4;
while(++cp<cpmax && *cp>='0' && *cp<='7')
{
c <<= 3;
c |= (*cp-'0');
}
default:
cp--;
}
stakputc(c);
cp++;
}
}
done:
c = staktell()-offset;
stakseek(offset);
return(c);
}

View File

@@ -0,0 +1,466 @@
/* $XConsortium: read.c /main/3 1995/11/01 16:29:22 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <error.h>
#include <ctype.h>
#include "defs.h"
#include "variables.h"
#include "lexstates.h"
#include "io.h"
#include "name.h"
#include "builtins.h"
#include "history.h"
#include "terminal.h"
#include "national.h"
#define R_FLAG 1 /* raw mode */
#define S_FLAG 2 /* save in history file */
#define A_FLAG 4 /* read into array */
#define D_FLAG 6 /* must be number of bits for all flags */
int b_read __PARAM__((int argc,char *argv[], __V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[]; __V_ *extra;){
register char *name;
register int r, flags=0, fd=0;
long timeout = 1000*sh.tmout;
int save_prompt;
NOT_USED(argc);
NOT_USED(extra);
while((r = optget(argv,sh_optread))) switch(r)
{
case 'A':
flags |= A_FLAG;
break;
case 't':
timeout = 1000*opt_num;
break;
case 'd':
if(opt_arg && *opt_arg!='\n')
flags |= ((*opt_arg)<< D_FLAG);
break;
case 'p':
if((fd = sh.cpipe[0])<=0)
error(ERROR_exit(1),e_query);
break;
case 'r':
flags |= R_FLAG;
break;
case 's':
/* save in history file */
flags |= S_FLAG;
break;
case 'u':
fd = (int)opt_num;
if(sh_inuse(fd))
fd = -1;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(!((r=sh.fdstatus[fd])&IOREAD) || !(r&(IOSEEK|IONOSEEK)))
r = sh_iocheckfd(fd);
if(fd<0 || !(r&IOREAD))
error(ERROR_system(1),e_file+4);
/* look for prompt */
if((name = *argv) && (name=strchr(name,'?')) && (r&IOTTY))
{
r = strlen(++name)+1;
if(sh.prompt=(char*)sfreserve(sfstderr,r,1))
{
memcpy(sh.prompt,name,r);
sfwrite(sfstderr,sh.prompt,r);
}
}
sh.timeout = 0;
save_prompt = sh.nextprompt;
sh.nextprompt = 0;
r=sh_readline(argv,fd,flags,timeout);
sh.nextprompt = save_prompt;
if(r==0 && (r=(sfeof(sh.sftable[fd])||sferror(sh.sftable[fd]))))
{
if(fd == sh.cpipe[0])
{
sh_pclose(sh.cpipe);
return(1);
}
}
sfclrerr(sh.sftable[fd]);
return(r);
}
/*
* here for read timeout
*/
static void timedout __PARAM__((__V_ *handle), (handle)) __OTORP__(__V_ *handle;){
sfclrlock((Sfio_t*)handle);
sh_exit(1);
}
/*
* This is the code to read a line and to split it into tokens
* <names> is an array of variable names
* <fd> is the file descriptor
* <flags> is union of -A, -r, -s, and contains delimiter if not '\n'
* <timeout> is number of milli-seconds until timeout
*/
int sh_readline __PARAM__((char **names, int fd, int flags,long timeout), (names, fd, flags, timeout)) __OTORP__(char **names; int fd; int flags;long timeout;){
register int c;
register unsigned char *cp;
register Namval_t *np;
register char *name, *val;
register Sfio_t *iop;
char *ifs;
unsigned char *cpmax;
char was_escape = 0;
char use_stak = 0;
int rel;
long array_index = 0;
__V_ *timeslot=0;
int delim = '\n';
int jmpval=0;
struct checkpt buff;
if(!(iop=sh.sftable[fd]) && !(iop=sh_iostream(fd)))
return(1);
if(flags>>D_FLAG) /* delimiter not new-line */
{
delim = ((unsigned)flags)>>D_FLAG;
if(sh.fdstatus[fd]&IOTTY)
tty_raw(fd,1);
}
/* set up state table based on IFS */
ifs = nv_getval(np=nv_scoped(IFSNOD));
if((flags&R_FLAG) && sh.ifstable['\\']==S_ESC)
sh.ifstable['\\'] = 0;
else if(!(flags&R_FLAG) && sh.ifstable['\\']==0)
sh.ifstable['\\'] = S_ESC;
sh.ifstable[delim] = S_NL;
if(delim!='\n')
{
sh.ifstable['\n'] = 0;
nv_putval(np, ifs, NV_RDONLY);
}
sh.ifstable[0] = S_EOF;
if(names && (name = *names))
{
if(val= strchr(name,'?'))
*val = 0;
np = nv_open(name,sh.var_tree,NV_NOASSIGN|NV_VARNAME);
if(flags&A_FLAG)
{
flags &= ~A_FLAG;
array_index = 1;
nv_unset(np);
nv_putsub(np,NIL(char*),0L);
}
else
name = *++names;
if(val)
*val = '?';
}
else
{
name = 0;
if(hashscope(sh.var_tree))
np = nv_search((char*)REPLYNOD,sh.var_tree,HASH_BUCKET);
else
np = REPLYNOD;
}
sfclrerr(iop);
if(timeout)
{
sh_pushcontext(&buff,1);
jmpval = sigsetjmp(buff.buff,0);
if(jmpval)
goto done;
timeslot = (__V_*)timeradd(timeout,0,timedout,(__V_*)iop);
}
if(!(cp = (unsigned char*)sfgetr(iop,delim,0)))
cp = (unsigned char*)sfgetr(iop,delim,-1);
if(timeslot)
timerdel(timeslot);
if(cp)
{
cpmax = cp + sfslen();
if(*(cpmax-1) != delim)
*(cpmax-1) = delim;
if(flags&S_FLAG)
sfwrite(sh.hist_ptr->histfp,(char*)cp,sfslen());
c = sh.ifstable[*cp++];
#ifndef SHOPT_MULTIBYTE
if(!name && (flags&R_FLAG)) /* special case single argument */
{
/* skip over leading blanks */
while(c==S_SPACE)
c = sh.ifstable[*cp++];
/* strip trailing delimiters */
if(cpmax[-1] == '\n')
cpmax--;
*cpmax =0;
if(cpmax>cp)
{
while((c=sh.ifstable[*--cpmax])==S_DELIM || c==S_SPACE);
cpmax[1] = 0;
}
nv_putval(np,(char*)cp-1,0);
goto done;
}
#endif /* !SHOPT_MULTIBYTE */
}
else
c = S_NL;
sh.nextprompt = 2;
rel= staktell();
/* val==0 at the start of a field */
val = 0;
while(1)
{
switch(c)
{
#ifdef SHOPT_MULTIBYTE
case S_MBYTE:
if(sh_strchr(ifs,(char*)cp-1)>=0)
{
c = mblen((char*)cp-1,MB_CUR_MAX);
cp[-1] = 0;
cp += (c-1);
c = S_DELIM;
}
else
c = 0;
continue;
#endif /*SHOPT_MULTIBYTE */
case S_ESC:
/* process escape character */
if((c = sh.ifstable[*cp++]) == S_NL)
was_escape = 1;
else
c = 0;
if(val)
{
stakputs(val);
use_stak = 1;
was_escape = 1;
*val = 0;
}
continue;
case S_EOF:
/* check for end of buffer */
if(val && *val)
{
stakputs(val);
use_stak = 1;
}
val = 0;
if(cp>=cpmax)
{
c = S_NL;
break;
}
/* eliminate null bytes */
c = sh.ifstable[*cp++];
if(!name && val && (c==S_SPACE||c==S_DELIM||c==S_MBYTE))
c = 0;
continue;
case S_NL:
if(was_escape)
{
was_escape = 0;
if((cp = (unsigned char*)sfgetr(iop,delim,0)) ||
(cp = (unsigned char*)sfgetr(iop,delim,-1)))
{
if(flags&S_FLAG)
sfwrite(sh.hist_ptr->histfp,(char*)cp,sfslen());
cpmax = cp + sfslen();
c = sh.ifstable[*cp++];
val=0;
if(!name && (c==S_SPACE || c==S_DELIM || c==S_MBYTE))
c = 0;
continue;
}
}
c = S_NL;
break;
case S_SPACE:
/* skip over blanks */
while(c==S_SPACE)
c = sh.ifstable[*cp++];
if(!val)
continue;
#ifdef SHOPT_MULTIBYTE
if(c==S_MBYTE)
{
if(sh_strchr(ifs,(char*)cp-1)>=0)
{
c = mblen((char*)cp-1,MB_CUR_MAX);
cp += (c-1);
c = S_DELIM;
}
else
c = 0;
}
#endif /* SHOPT_MULTIBYTE */
if(c!=S_DELIM)
break;
/* FALL THRU */
case S_DELIM:
if(name)
{
/* skip over trailing blanks */
while((c=sh.ifstable[*cp++])==S_SPACE);
break;
}
case 0:
was_escape = 0;
val = (char*)(cp-1);
/* skip over word characters */
while(1)
{
while((c=sh.ifstable[*cp++])==0);
if(name || c==S_NL || c==S_ESC || c==S_EOF || c==S_MBYTE)
break;
}
if(c!=S_MBYTE)
cp[-1] = 0;
continue;
}
/* assign value and advance to next variable */
if(!val)
val = "";
if(use_stak)
{
stakputs(val);
stakputc(0);
val = stakptr(rel);
}
if(!name && *val)
{
/* strip off trailing delimiters */
register char *cp = val + strlen(val);
register int n;
while((n=sh.ifstable[*--cp])==S_DELIM || n==S_SPACE);
cp[1] = 0;
}
nv_putval(np,val,0);
val = 0;
if(use_stak)
{
stakseek(rel);
use_stak = 0;
}
if(array_index)
{
nv_putsub(np, NIL(char*), array_index++);
if(c!=S_NL)
continue;
name = *++names;
}
while(1)
{
if(sh_isoption(SH_ALLEXPORT)&&!strchr(nv_name(np),'.'))
nv_onattr(np,NV_EXPORT);
if(name)
{
nv_close(np);
np = nv_open(name,sh.var_tree,NV_NOASSIGN|NV_VARNAME);
name = *++names;
}
else
np = 0;
if(c!=S_NL)
break;
if(!np)
goto done;
nv_putval(np, "", 0);
}
}
done:
nv_close(np);
if(timeout)
sh_popcontext(&buff);
if((flags>>D_FLAG) && (sh.fdstatus[fd]&IOTTY))
tty_cooked(fd);
if(flags&S_FLAG)
hist_flush(sh.hist_ptr);
return(jmpval);
}

View File

@@ -0,0 +1,212 @@
/* $XConsortium: sleep.c /main/3 1995/11/01 16:29:36 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <error.h>
#include <errno.h>
#include "builtins.h"
#include "FEATURE/time"
#include "FEATURE/poll"
#ifdef _NEXT_SOURCE
# define sleep _ast_sleep
#endif /* _NEXT_SOURCE */
#ifdef _lib_poll_notimer
# undef _lib_poll
#endif /* _lib_poll_notimer */
int b_sleep __PARAM__((register int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(register int argc;char *argv[];__V_ *extra;){
register char *cp;
register double d;
time_t tloc = 0;
NOT_USED(extra);
while((argc = optget(argv,sh_optsleep))) switch(argc)
{
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors || !(cp= *argv) || !(strmatch(cp,e_numeric)))
error(ERROR_usage(2),optusage((char*)0));
if((d=atof(cp)) > 1.0)
{
sfsync(sh.outpool);
time(&tloc);
tloc += (time_t)(d+.5);
}
while(1)
{
time_t now;
errno = 0;
sh.lastsig=0;
sh_delay(d);
if(tloc==0 || errno!=EINTR || sh.lastsig)
break;
sh_sigcheck();
if(tloc < (now=time(NIL(time_t*))))
break;
d = (double)(tloc-now);
if(sh.sigflag[SIGALRM]&SH_SIGTRAP)
sh_timetraps();
}
return(0);
}
static char expired;
static void completed __PARAM__((__V_ * handle), (handle)) __OTORP__(__V_ * handle;){
NOT_USED(handle);
expired = 1;
}
unsigned sleep __PARAM__((unsigned sec), (sec)) __OTORP__(unsigned sec;){
pid_t newpid, curpid=getpid();
__V_ *tp;
expired = 0;
sh.lastsig = 0;
tp = (__V_*)timeradd(1000*sec, 0, completed, (__V_*)0);
do
{
pause();
if(sh.sigflag[SIGALRM]&SH_SIGTRAP)
sh_timetraps();
if((newpid=getpid()) != curpid)
{
curpid = newpid;
alarm(1);
}
}
while(!expired && sh.lastsig==0);
if(!expired)
timerdel(tp);
sh_sigcheck();
return(0);
}
/*
* delay execution for time <t>
*/
void sh_delay __PARAM__((double t), (t)) __OTORP__(double t;){
register int n = (int)t;
#ifdef _lib_poll
struct pollfd fd;
if(t<=0)
return;
else if(n > 30)
{
sleep(n);
t -= n;
}
if(n=(int)(1000*t))
poll(&fd,0,n);
#else
# if defined(_lib_select) && defined(_mem_tv_usec_timeval)
struct timeval timeloc;
if(t<=0)
return;
timeloc.tv_sec = n;
timeloc.tv_usec = 1000000*(t-(double)n);
select(0,(fd_set*)0,(fd_set*)0,(fd_set*)0,&timeloc);
# else
# ifdef _lib_select
/* for 9th edition machines */
if(t<=0)
return;
if(n > 30)
{
sleep(n);
t -= n;
}
if(n=(int)(1000*t))
select(0,(fd_set*)0,(fd_set*)0,n);
# else
struct tms tt;
if(t<=0)
return;
sleep(n);
t -= n;
if(t)
{
clock_t begin = times(&tt);
if(begin==0)
return;
t *= sh.lim.clk_tck;
n += (t+.5);
while((times(&tt)-begin) < n);
}
# endif
# endif
#endif /* _lib_poll */
}

View File

@@ -0,0 +1,579 @@
/* $XConsortium: test.c /main/5 1995/12/12 14:46:01 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <ctype.h>
#include <error.h>
#include <ls.h>
#include "io.h"
#include "terminal.h"
#include "test.h"
#include "builtins.h"
#include "FEATURE/externs"
#ifndef _lib_setregid
# undef _lib_setreuid
#endif /* _lib_setregid */
#if defined(_lib_setreuid) && ! defined(_AIX) && ! defined(__osf__)
extern __MANGLE__ int setreuid __PROTO__((uid_t,uid_t));
extern __MANGLE__ int setregid __PROTO__((uid_t,uid_t));
#endif /* _lib_setreuid */
#define permission(a,f) (sh_access(a,f)==0)
static time_t test_time __PROTO__((const char*, const char*));
static int test_stat __PROTO__((const char*, struct stat*));
static int test_mode __PROTO__((const char*));
static struct stat statb;
/* single char string compare */
#define c_eq(a,c) (*a==c && *(a+1)==0)
/* two character string compare */
#define c2_eq(a,c1,c2) (*a==c1 && *(a+1)==c2 && *(a+2)==0)
static char *nxtarg __PROTO__((int));
static int expr __PROTO__((int));
static int e3 __PROTO__((void));
static int ap, ac;
static char **av;
int b_test __PARAM__((int argc, char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc; char *argv[];__V_ *extra;){
register char *cp = argv[0];
register int not;
NOT_USED(extra);
av = argv;
ap = 1;
if(c_eq(cp,'['))
{
cp = argv[--argc];
if(!c_eq(cp, ']'))
error(ERROR_exit(2),e_missing,"']'");
}
if(argc <= 1)
return(1);
cp = argv[1];
not = c_eq(cp,'!');
/* posix portion for test */
switch(argc)
{
case 5:
if(!not)
break;
argv++;
/* fall through */
case 4:
{
register int op = sh_lookup(cp=argv[2],shtab_testops);
if(op&TEST_BINOP)
break;
if(!op)
{
if(argc==5)
break;
if(not && cp[0]=='-' && cp[2]==0)
return(test_unop(cp[1],argv[3]));
error(ERROR_exit(2),e_badop,cp);
}
return(test_binop(op,argv[1],argv[3])^(argc!=5));
}
case 3:
if(not)
return(*argv[2]!=0);
if(cp[0] != '-' || cp[2])
break;
return(!test_unop(cp[1],argv[2]));
case 2:
return(*cp==0);
}
if(argc==5)
argv--;
ac = argc;
return(!expr(0));
}
/*
* evaluate a test expression.
* flag is 0 on outer level
* flag is 1 when in parenthesis
* flag is 2 when evaluating -a
*/
static int expr __PARAM__((int register flag), (flag)) __OTORP__(int register flag;){
register int r;
register char *p;
r = e3();
while(ap < ac)
{
p = nxtarg(0);
/* check for -o and -a */
if(flag && c_eq(p,')'))
{
ap--;
break;
}
if(*p=='-' && *(p+2)==0)
{
if(*++p == 'o')
{
if(flag==2)
{
ap--;
break;
}
r |= expr(3);
continue;
}
else if(*p == 'a')
{
r &= expr(2);
continue;
}
}
if(flag==0)
break;
error(ERROR_exit(2),e_badsyntax);
}
return(r);
}
static char *nxtarg __PARAM__((int mt), (mt)) __OTORP__(int mt;){
if(ap >= ac)
{
if(mt)
{
ap++;
return(0);
}
error(ERROR_exit(2),e_argument);
}
return(av[ap++]);
}
static e3 __PARAM__((void), ()){
register char *arg, *cp;
register int op;
char *binop;
arg=nxtarg(0);
if(c_eq(arg, '!'))
return(!e3());
if(c_eq(arg, '('))
{
op = expr(1);
cp = nxtarg(0);
if(!c_eq(cp, ')'))
error(ERROR_exit(2),e_missing,"')'");
return(op);
}
cp = nxtarg(1);
if(cp!=0 && (c_eq(cp,'=') || c2_eq(cp,'!','=')))
goto skip;
if(c2_eq(arg,'-','t'))
{
if(cp && isdigit(*cp))
return(*(cp+1)?0:tty_check(*cp-'0'));
else
{
/* test -t with no arguments */
ap--;
return(tty_check(1));
}
}
if(*arg=='-' && arg[2]==0)
{
op = arg[1];
if(!cp)
{
/* for backward compatibility with new flags */
if(op==0 || !strchr(test_opchars+10,op))
return(1);
error(ERROR_exit(2),e_argument);
}
if(strchr(test_opchars,op))
return(test_unop(op,cp));
}
if(!cp)
{
ap--;
return(*arg!=0);
}
skip:
op = sh_lookup(binop=cp,shtab_testops);
if(!(op&TEST_BINOP))
cp = nxtarg(0);
if(!op)
error(ERROR_exit(2),e_badop,binop);
return(test_binop(op,arg,cp));
}
int test_unop __PARAM__((register int op,register const char *arg), (op, arg)) __OTORP__(register int op;register const char *arg;){
switch(op)
{
case 'r':
return(permission(arg, R_OK));
case 'w':
return(permission(arg, W_OK));
case 'x':
return(permission(arg, X_OK));
case 'V':
#ifdef SHOPT_FS_3D
{
register int offset = staktell();
if(stat(arg,&statb)<0 || !S_ISREG(statb.st_mode))
return(0);
/* add trailing / */
stakputs(arg);
stakputc('/');
stakputc(0);
arg = (const char*)stakptr(offset);
stakseek(offset);
/* FALL THRU */
}
#else
return(0);
#endif /* SHOPT_FS_3D */
case 'd':
return(test_stat(arg,&statb)>=0 && S_ISDIR(statb.st_mode));
case 'c':
return(test_stat(arg,&statb)>=0 && S_ISCHR(statb.st_mode));
case 'b':
return(test_stat(arg,&statb)>=0 && S_ISBLK(statb.st_mode));
case 'f':
return(test_stat(arg,&statb)>=0 && S_ISREG(statb.st_mode));
case 'u':
return(test_mode(arg)&S_ISUID);
case 'g':
return(test_mode(arg)&S_ISGID);
case 'k':
#ifdef S_ISVTX
return(test_mode(arg)&S_ISVTX);
#else
return(0);
#endif /* S_ISVTX */
case 'L':
case 'h': /* undocumented, and hopefully will disappear */
{
struct stat statb;
if(*arg==0 || lstat(arg,&statb)<0)
return(0);
return(S_ISLNK(statb.st_mode));
}
case 'C':
#ifdef S_ISCTG
return(test_stat(arg,&statb)>=0 && S_ISCTG(statb.st_mode));
#else
return(0);
#endif /* S_ISCTG */
case 'H':
#ifdef S_ISCDF
{
register int offset = staktell();
if(test_stat(arg,&statb)>=0 && S_ISCDF(statb.st_mode))
return(1);
stakputs(arg);
stakputc('+');
stakputc(0);
arg = (const char*)stakptr(offset);
stakseek(offset);
return(test_stat(arg,&statb)>=0 && S_ISCDF(statb.st_mode));
}
#else
return(0);
#endif /* S_ISCDF */
case 'S':
#ifdef S_ISSOCK
return(test_stat(arg,&statb)>=0 && S_ISSOCK(statb.st_mode));
#else
return(0);
#endif /* S_ISSOCK */
case 'p':
return(test_stat(arg,&statb)>=0 && S_ISFIFO(statb.st_mode));
case 'n':
return(*arg != 0);
case 'z':
return(*arg == 0);
case 's':
case 'O':
case 'G':
{
struct stat statb;
if(*arg==0 || test_stat(arg,&statb)<0)
return(0);
if(op=='s')
return(statb.st_size>0);
else if(op=='O')
return(statb.st_uid==sh.userid);
return(statb.st_gid==sh.groupid);
}
case 'a':
case 'e':
return(permission(arg, F_OK));
case 'o':
op = sh_lookup(arg,shtab_options);
return(op && sh_isoption((1L<<op))!=0);
case 't':
if(isdigit(*arg) && arg[1]==0)
return(tty_check(*arg-'0'));
return(0);
default:
{
static char a[3] = "-?";
a[1]= op;
error(ERROR_exit(2),e_badop,a);
/* NOTREACHED */
}
}
}
test_binop __PARAM__((register int op,const char *left,const char *right), (op, left, right)) __OTORP__(register int op;const char *left;const char *right;){
register double lnum,rnum;
if(op&TEST_ARITH)
{
lnum = sh_arith(left);
rnum = sh_arith(right);
}
switch(op)
{
/* op must be one of the following values */
case TEST_AND:
case TEST_OR:
ap--;
return(*left!=0);
case TEST_PEQ:
return(strmatch(left, right));
case TEST_PNE:
return(!strmatch(left, right));
case TEST_SGT:
return(strcoll(left, right)>0);
case TEST_SLT:
return(strcoll(left, right)<0);
case TEST_SEQ:
return(strcmp(left, right)==0);
case TEST_SNE:
return(strcmp(left, right)!=0);
case TEST_EF:
return(test_inode(left,right));
case TEST_NT:
return(test_time(left,right)>0);
case TEST_OT:
return(test_time(left,right)<0);
case TEST_EQ:
return(lnum==rnum);
case TEST_NE:
return(lnum!=rnum);
case TEST_GT:
return(lnum>rnum);
case TEST_LT:
return(lnum<rnum);
case TEST_GE:
return(lnum>=rnum);
case TEST_LE:
return(lnum<=rnum);
}
/* NOTREACHED */
}
/*
* returns the modification time of f1 - modification time of f2
*/
static time_t test_time __PARAM__((const char *file1,const char *file2), (file1, file2)) __OTORP__(const char *file1;const char *file2;){
struct stat statb1,statb2;
if(test_stat(file1,&statb1)<0)
statb1.st_mtime = 0;
if(test_stat(file2,&statb2)<0)
statb2.st_mtime = 0;
return(statb1.st_mtime-statb2.st_mtime);
}
/*
* return true if inode of two files are the same
*/
test_inode __PARAM__((const char *file1,const char *file2), (file1, file2)) __OTORP__(const char *file1;const char *file2;){
struct stat stat1,stat2;
if(test_stat(file1,&stat1)>=0 && test_stat(file2,&stat2)>=0)
if(stat1.st_dev == stat2.st_dev && stat1.st_ino == stat2.st_ino)
return(1);
return(0);
}
/*
* This version of access checks against effective uid/gid
* The static buffer statb is shared with test_mode.
*/
sh_access __PARAM__((register const char *name, register int mode), (name, mode)) __OTORP__(register const char *name; register int mode;){
if(*name==0)
return(-1);
if(strmatch(name,(char*)e_devfdNN))
return(sh_ioaccess(atoi(name+8),mode));
/* can't use access function for execute permission with root */
if(mode==X_OK && sh.euserid==0)
goto skip;
if(sh.userid==sh.euserid && sh.groupid==sh.egroupid)
return(access(name,mode));
#ifdef _lib_setreuid
/* swap the real uid to effective, check access then restore */
/* first swap real and effective gid, if different */
if(sh.groupid==sh.euserid || setregid(sh.egroupid,sh.groupid)==0)
{
/* next swap real and effective uid, if needed */
if(sh.userid==sh.euserid || setreuid(sh.euserid,sh.userid)==0)
{
mode = access(name,mode);
/* restore ids */
if(sh.userid!=sh.euserid)
setreuid(sh.userid,sh.euserid);
if(sh.groupid!=sh.egroupid)
setregid(sh.groupid,sh.egroupid);
return(mode);
}
else if(sh.groupid!=sh.egroupid)
setregid(sh.groupid,sh.egroupid);
}
#endif /* _lib_setreuid */
skip:
if(test_stat(name, &statb) == 0)
{
if(mode == F_OK)
return(mode);
else if(sh.euserid == 0)
{
if(!S_ISREG(statb.st_mode) || mode!=X_OK)
return(0);
/* root needs execute permission for someone */
mode = (S_IXUSR|S_IXGRP|S_IXOTH);
}
else if(sh.euserid == statb.st_uid)
mode <<= 6;
else if(sh.egroupid == statb.st_gid)
mode <<= 3;
#ifdef _lib_getgroups
/* on some systems you can be in several groups */
else
{
static int maxgroups = 0;
gid_t *groups;
register int n;
if(maxgroups==0)
{
/* first time */
if((maxgroups=getgroups(0, (gid_t *)NULL)) <= 0)
{
/* pre-POSIX system */
maxgroups=NGROUPS_MAX;
}
}
groups = (gid_t*)stakalloc((maxgroups+1)*sizeof(gid_t));
n = getgroups(maxgroups,groups);
while(--n >= 0)
{
if(groups[n] == statb.st_gid)
{
mode <<= 3;
break;
}
}
}
# endif /* _lib_getgroups */
if(statb.st_mode & mode)
return(0);
}
return(-1);
}
/*
* Return the mode bits of file <file>
* If <file> is null, then the previous stat buffer is used.
* The mode bits are zero if the file doesn't exist.
*/
static int test_mode __PARAM__((register const char *file), (file)) __OTORP__(register const char *file;){
if(file && (*file==0 || test_stat(file,&statb)<0))
return(0);
return(statb.st_mode);
}
/*
* do an fstat() for /dev/fd/n, otherwise stat()
*/
static int test_stat __PARAM__((const char *name,struct stat *buff), (name, buff)) __OTORP__(const char *name;struct stat *buff;){
if(strmatch(name,(char*)e_devfdNN))
return(fstat(atoi(name+8),buff));
else
return(stat(name,buff));
}

View File

@@ -0,0 +1,369 @@
/* $XConsortium: trap.c /main/4 1996/08/16 15:31:57 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <ctype.h>
#include "jobs.h"
#include "builtins.h"
#define L_FLAG 1
#define S_FLAG 2
static const char trapfmt[] = "trap -- %s %s\n";
static int sig_number __PROTO__((const char*));
static void sig_list __PROTO__((int));
int b_trap __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register char *arg = argv[1];
register int sig, pflag = 0;
NOT_USED(argc);
NOT_USED(extra);
while (sig = optget(argv, sh_opttrap)) switch (sig)
{
case 'p':
pflag=1;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
if(arg = *argv)
{
register int clear;
char *action = arg;
if(!pflag)
{
/* first argument all digits or - means clear */
while(isdigit(*arg))
arg++;
clear = (arg!=action && *arg==0);
if(!clear)
{
++argv;
if(*action=='-' && action[1]==0)
clear++;
}
while(!argv[0])
error(ERROR_exit(1),e_condition);
}
while(arg = *argv++)
{
sig = sig_number(arg);
if(sig<0)
{
error(2,e_trap,arg);
return(1);
}
/* internal traps */
if(sig&SH_TRAP)
{
sig &= ~SH_TRAP;
if(sig>SH_DEBUGTRAP)
{
error(2,e_trap,arg);
return(1);
}
if(pflag)
{
if(arg=sh.st.trap[sig])
sfputr(sfstdout,sh_fmtq(arg),'\n');
continue;
}
if(sh.st.trap[sig])
free(sh.st.trap[sig]);
sh.st.trap[sig] = 0;
if(!clear && *action)
sh.st.trap[sig] = strdup(action);
if(sig == SH_DEBUGTRAP)
{
if(sh.st.trap[sig])
sh.trapnote |= SH_SIGTRAP;
else
sh.trapnote = 0;
}
continue;
}
if(sig>sh.sigmax)
{
error(2,e_trap,arg);
return(1);
}
else if(pflag)
{
if(arg=sh.st.trapcom[sig])
sfputr(sfstdout,sh_fmtq(arg),'\n');
}
else if(clear)
sh_sigclear(sig);
else
{
if(sig >= sh.st.trapmax)
sh.st.trapmax = sig+1;
if(arg=sh.st.trapcom[sig])
free(arg);
sh.st.trapcom[sig] = strdup(action);
sh_sigtrap(sig);
}
}
}
else /* print out current traps */
sig_list(-1);
return(0);
}
int b_kill __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register char *signame;
register int sig=SIGTERM, flag=0, n;
NOT_USED(argc);
NOT_USED(extra);
while((n = optget(argv,sh_optkill))) switch(n)
{
case ':':
if((signame=argv[opt_index++]) && (sig=sig_number(signame+1))>=0)
{
if(argv[opt_index] && strcmp(argv[opt_index],"--")==0)
opt_index++;
goto endopts;
}
opt_index--;
error(2, opt_arg);
break;
case 'n':
sig = (int)opt_num;
break;
case 's':
flag |= S_FLAG;
signame = opt_arg;
break;
case 'l':
flag |= L_FLAG;
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
endopts:
argv += opt_index;
if(error_info.errors || flag==(L_FLAG|S_FLAG) || (!(*argv) && !(flag&L_FLAG)))
error(ERROR_usage(2),optusage((char*)0));
/* just in case we send a kill -9 $$ */
sfsync(sfstderr);
if(flag&L_FLAG)
{
if(!(*argv))
sig_list(0);
else while(signame = *argv++)
{
if(isdigit(*signame))
sig_list((atoi(signame)&0177)+1);
else
{
if((sig=sig_number(signame))<0)
{
sh.exitval = 2;
error(ERROR_exit(1),e_nosignal,signame);
}
sfprintf(sfstdout,"%d\n",sig);
}
}
return(sh.exitval);
}
if(flag&S_FLAG)
{
if((sig=sig_number(signame)) < 0 || sig > sh.sigmax)
error(ERROR_exit(1),e_nosignal,signame);
}
if(job_walk(sfstdout,job_kill,sig,argv))
sh.exitval = 1;
return(sh.exitval);
}
/*
* Given the name or number of a signal return the signal number
*/
static int sig_number __PARAM__((const char *string), (string)) __OTORP__(const char *string;){
register int n;
char *last;
if(isdigit(*string))
{
n = strtol(string,&last,10);
if(*last)
n = -1;
}
else
{
register int c;
n = staktell();
do
{
c = *string++;
if(islower(c))
c = toupper(c);
stakputc(c);
}
while(c);
stakseek(n);
init_shtab_signals();
n = sh_lookup(stakptr(n),shtab_signals);
n &= (1<<SH_SIGBITS)-1;
if(n < SH_TRAP)
n--;
}
return(n);
}
/*
* if <flag> is positive, then print signal name corresponding to <flag>
* if <flag> is zero, then print all signal names
* if <flag> is negative, then print all traps
*/
static void sig_list __PARAM__((register int flag), (flag)) __OTORP__(register int flag;){
register const struct shtable2 *tp;
register int sig = sh.sigmax+1;
const char *names[SH_TRAP];
const char *traps[SH_DEBUGTRAP+1];
init_shtab_signals();
tp=shtab_signals;
if(flag==0)
{
/* not all signals may be defined, so initialize */
while(--sig >= 0)
names[sig] = 0;
for(sig=SH_DEBUGTRAP; sig>=0; sig--)
traps[sig] = 0;
}
while(*tp->sh_name)
{
sig = tp->sh_number;
sig &= ((1<<SH_SIGBITS)-1);
if(sig==flag)
{
sfprintf(sfstdout,"%s\n",tp->sh_name);
return;
}
else if(sig&SH_TRAP)
traps[sig&~SH_TRAP] = (char*)tp->sh_name;
else if(sig < sizeof(names)/sizeof(char*))
names[sig] = (char*)tp->sh_name;
tp++;
}
if(flag > 0)
sfprintf(sfstdout,"%d\n",flag-1);
else if(flag<0)
{
/* print the traps */
register char *trap,*sname,**trapcom;
sig = sh.st.trapmax;
/* use parent traps if otrapcom is set (for $(trap) */
trapcom = (sh.st.otrapcom?sh.st.otrapcom:sh.st.trapcom);
while(--sig >= 0)
{
if(!(trap=trapcom[sig]))
continue;
if(!(sname=(char*)names[sig+1]))
{
sname="SIG??";
sname[3] = (sig/10)+'0';
sname[4] = (sig%10)+'0';
}
sfprintf(sfstdout,trapfmt,sh_fmtq(trap),sname);
}
for(sig=SH_DEBUGTRAP; sig>=0; sig--)
{
if(!(trap=sh.st.trap[sig]))
continue;
sfprintf(sfstdout,trapfmt,sh_fmtq(trap),traps[sig]);
}
}
else
{
/* print all the signal names */
for(sig=2; sig <= sh.sigmax; sig++)
{
if(names[sig])
sfputr(sfstdout,names[sig],'\n');
else
sfprintf(sfstdout,"SIG%d\n",sig-1);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,244 @@
/* $XConsortium: ulimit.c /main/3 1995/11/01 16:30:47 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <sfio.h>
#include <error.h>
#include <shell.h>
#ifdef __osf__
#include <sys/resource.h>
#endif
#include "builtins.h"
#include "ulimit.h"
#ifdef _no_ulimit
int b_ulimit __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
NOT_USED(argc);
NOT_USED(argv);
NOT_USED(extra);
error(ERROR_exit(2),e_nosupport);
return(0);
}
#else
#define HARD 1
#define SOFT 2
int b_ulimit __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register char *limit;
register int flag = 0, mode=0, n;
#ifdef _lib_getrlimit
struct rlimit rlp;
#endif /* _lib_getrlimit */
const Shtable_t *tp;
int label, unit, noargs;
long i;
NOT_USED(extra);
while((n = optget(argv,sh_optulimit))) switch(n)
{
case 'H':
mode |= HARD;
continue;
case 'S':
mode |= SOFT;
continue;
case 'f':
flag |= (1<<1);
break;
case 'a':
#ifdef _lib_ulimit
flag = (1<<1);
break;
#else
flag = (0x2f
# ifdef RLIMIT_RSS
|(1<<4)
# endif /* RLIMIT_RSS */
# ifdef RLIMIT_NOFILE
|(1<<6)
# endif /* RLIMIT_NOFILE */
# ifdef RLIMIT_VMEM
|(1<<7)
# endif /* RLIMIT_VMEM */
);
break;
case 't':
flag |= 1;
break;
# ifdef RLIMIT_RSS
case 'm':
flag |= (1<<4);
break;
# endif /* RLIMIT_RSS */
case 'd':
flag |= (1<<2);
break;
case 's':
flag |= (1<<3);
break;
case 'c':
flag |= (1<<5);
break;
# ifdef RLIMIT_NOFILE
case 'n':
flag |= (1<<6);
break;
# endif /* RLIMIT_NOFILE */
# ifdef RLIMIT_VMEM
case 'v':
flag |= (1<<7);
break;
# endif /* RLIMIT_VMEM */
#endif /* _lib_ulimit */
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
limit = argv[opt_index];
/* default to -f */
if(noargs=(flag==0))
flag |= (1<<1);
/* only one option at a time for setting */
label = (flag&(flag-1));
if(error_info.errors || (limit && label) || argc>opt_index+1)
error(ERROR_usage(2),optusage((char*)0));
tp = shtab_limits;
if(mode==0)
mode = (HARD|SOFT);
for(; flag; tp++,flag>>=1)
{
if(!(flag&1))
continue;
n = tp->sh_number>>11;
unit = tp->sh_number&0x7ff;
if(limit)
{
if(sh.subshell)
sh_subfork();
if(strcmp(limit,e_unlimited)==0)
i = INFINITY;
else
{
char *last;
if((i=sh_strnum(limit,&last)) < 0 || *last)
error(ERROR_system(1),e_number,limit);
i *= unit;
}
#ifdef _lib_getrlimit
if(getrlimit(n,&rlp) <0)
error(ERROR_system(1),e_number,limit);
if(mode&HARD)
rlp.rlim_max = i;
if(mode&SOFT)
rlp.rlim_cur = i;
if(setrlimit(n,&rlp) <0)
error(ERROR_system(1),e_overlimit,limit);
#else
if((i=vlimit(n,i)) < 0)
error(ERROR_system(1),e_number,limit);
#endif /* _lib_getrlimit */
}
else
{
#ifdef _lib_getrlimit
if(getrlimit(n,&rlp) <0)
error(ERROR_system(1),e_number,limit);
if(mode&HARD)
i = rlp.rlim_max;
if(mode&SOFT)
i = rlp.rlim_cur;
#else
# ifdef _lib_ulimit
n--;
# endif /* _lib_ulimit */
i = -1;
if((i=vlimit(n,i)) < 0)
error(ERROR_system(1),e_number,limit);
#endif /* _lib_getrlimit */
if(label)
sfputr(sfstdout,tp->sh_name,' ');
if(i!=INFINITY || noargs)
{
if(!noargs)
i += (unit-1);
sfprintf(sfstdout,"%d\n",i/unit);
}
else
sfputr(sfstdout,e_unlimited,'\n');
}
}
return(0);
}
#endif /* _no_ulimit */

View File

@@ -0,0 +1,137 @@
/* $XConsortium: umask.c /main/3 1995/11/01 16:31:02 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <sfio.h>
#include <error.h>
#include <ctype.h>
#include <ls.h>
#include <shell.h>
#include "builtins.h"
int b_umask __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register char *mask;
register int flag = 0, sflag = 0;
NOT_USED(extra);
while((argc = optget(argv,sh_optumask))) switch(argc)
{
case 'S':
sflag++;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
if(error_info.errors)
error(ERROR_usage(2),optusage((char*)0));
argv += opt_index;
if(mask = *argv)
{
register int c;
if(isdigit(*mask))
{
while(c = *mask++)
{
if (c>='0' && c<='7')
flag = (flag<<3) + (c-'0');
else
error(ERROR_exit(1),e_number,*argv);
}
}
else
{
char *cp = mask;
flag = umask(0);
c = strperm(cp,&cp,~flag);
if(*cp)
{
umask(flag);
error(ERROR_exit(1),e_format,mask);
}
flag = (~c&0777);
}
umask(flag);
}
else
{
umask(flag=umask(0));
if(sflag)
sfprintf(sfstdout,"%s\n",fmtperm(~flag&0777));
else
sfprintf(sfstdout,"%0#4o\n",flag);
}
return(0);
}

View File

@@ -0,0 +1,281 @@
/* $XConsortium: whence.c /main/3 1995/11/01 16:31:17 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <error.h>
#include "shtable.h"
#include "name.h"
#include "path.h"
#include "shlex.h"
#include "builtins.h"
#define P_FLAG 1
#define V_FLAG 2
#define A_FLAG 4
#define F_FLAG 010
#define X_FLAG 020
static int whence __PROTO__((char**, int));
/*
* command is called with argc==0 when checking for -V or -v option
* In this case return 0 when -v or -V or unknown option, otherwise
* the shift count to the command is returned
*/
int b_command __PARAM__((register int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(register int argc;char *argv[];__V_ *extra;){
register int n, flags=0;
NOT_USED(extra);
opt_index = opt_char = 0;
while((n = optget(argv,sh_optcommand))) switch(n)
{
case 'p':
sh_onstate(SH_DEFPATH);
break;
case 'v':
flags |= X_FLAG;
break;
case 'V':
flags |= V_FLAG;
break;
case ':':
if(argc==0)
return(0);
error(2, opt_arg);
break;
case '?':
if(argc==0)
return(0);
error(ERROR_usage(2), opt_arg);
break;
}
if(argc==0)
return(flags?0:opt_index);
argv += opt_index;
if(error_info.errors || !*argv)
error(ERROR_usage(2),optusage((char*)0));
return(whence(argv, flags));
}
/*
* for the whence command
*/
int b_whence __PARAM__((int argc,char *argv[],__V_ *extra), (argc, argv, extra)) __OTORP__(int argc;char *argv[];__V_ *extra;){
register int flags=0, n;
NOT_USED(argc);
NOT_USED(extra);
if(*argv[0]=='t')
flags = V_FLAG;
while((n = optget(argv,sh_optwhence))) switch(n)
{
case 'a':
flags |= A_FLAG;
/* FALL THRU */
case 'v':
flags |= V_FLAG;
break;
case 'f':
flags |= F_FLAG;
break;
case 'p':
flags |= P_FLAG;
break;
case ':':
error(2, opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}
argv += opt_index;
if(error_info.errors || !*argv)
error(ERROR_usage(2),optusage((char*)0));
return(whence(argv, flags));
}
static int whence __PARAM__((char **argv, register int flags), (argv, flags)) __OTORP__(char **argv; register int flags;){
register const char *name;
register Namval_t *np;
register const char *cp;
register aflag,r=0;
register const char *msg;
int notrack = 1;
while(name= *argv++)
{
aflag = ((flags&A_FLAG)!=0);
cp = 0;
np = 0;
if(flags&P_FLAG)
goto search;
/* reserved words first */
if(sh_lookup(name,shtab_reserved))
{
sfprintf(sfstdout,"%s%s\n",name,(flags&V_FLAG)?ERROR_translate(is_reserved,1):"");
if(!aflag)
continue;
aflag++;
}
/* non-tracked aliases */
if((np=nv_search(name,sh.alias_tree,0))
&& !nv_isnull(np) && !(notrack=nv_isattr(np,NV_TAGGED))
&& (cp=nv_getval(np)))
{
if(flags&V_FLAG)
{
if(nv_isattr(np,NV_EXPORT))
msg = is_xalias;
else
msg = is_alias;
sfprintf(sfstdout,ERROR_translate(msg,1),name);
}
sfputr(sfstdout,sh_fmtq(cp),'\n');
if(!aflag)
continue;
cp = 0;
aflag++;
}
/* built-ins and functions next */
if((np=nv_search(name,sh.fun_tree,0)) && (!nv_isnull(np) || nv_isattr(np,NV_FUNCTION)))
{
if(is_abuiltin(np) && (cp=np->nvenv))
goto search;
if((flags&F_FLAG) && nv_isattr(np,NV_FUNCTION))
if(!(np=nv_search(name,sh.bltin_tree,0)) || nv_isnull(np))
goto search;
cp = "";
if(flags&V_FLAG)
{
if(nv_isnull(np))
{
if(!nv_isattr(np,NV_FUNCTION))
goto search;
cp = is_ufunction;
}
else if(is_abuiltin(np))
cp = is_builtin;
else if(nv_isattr(np,NV_EXPORT))
cp = is_xfunction;
else
cp = is_function;
}
sfprintf(sfstdout,"%s%s\n",name,ERROR_translate(cp,1));
if(!aflag)
continue;
cp = 0;
aflag++;
}
search:
if(sh_isstate(SH_DEFPATH))
{
cp=0;
notrack=1;
}
if(path_search(name,cp,2))
cp = name;
else
cp = sh.lastpath;
sh.lastpath = 0;
if(cp)
{
if(flags&V_FLAG)
{
if(*cp!= '/')
{
if(!np || nv_isnull(np))
sfprintf(sfstdout,"%s%s\n",name,ERROR_translate(is_ufunction,1));
continue;
}
sfputr(sfstdout,sh_fmtq(name),' ');
/* built-in version of program */
if(np && is_abuiltin(np) && np->nvenv && strcmp(np->nvenv,cp)==0)
msg = is_builtver;
/* tracked aliases next */
else if(!notrack && *name == '/')
msg = "is";
else
msg = is_talias;
sfputr(sfstdout,ERROR_translate(msg,1),' ');
}
sfputr(sfstdout,sh_fmtq(cp),'\n');
}
else if(aflag<=1)
{
r |= 1;
if(flags&V_FLAG)
{
sfprintf(sfstdout,ERROR_translate(e_found,1),sh_fmtq(name));
sfputc(sfstdout,'\n');
}
}
}
return(r);
}

View File

@@ -0,0 +1,625 @@
./" $XConsortium: builtins.mm /main/3 1995/11/01 16:24:21 rswiston $
.ds DT July 9, 1993 \" use troff -mm
.PM BP
.nr C 3
.nr N 2
.SA 1 \" right justified
.TL "311466-6713" "49059-6" \" charging case filing case
Guidelines for writing \f5ksh-93\fP built-in commands
.AU "David G. Korn" DGK MH 11267 7975 3C-526B "(research!dgk)"
.TM 11267-930???-93 \" technical memo + TM numbers
.AS 2 \" abstract start for TM
One of the features of \f5ksh93\fP, the latest version of \f5ksh\fP,
is the ability to add built-in commands at run time.
This feature only works on operating systems that have the ability
to load and link code into the current process at run time.
Some examples of the systems that have this feature
are System V Release 4, Solaris, Sun OS, HP-UX Release 8 and above
and AIX 3.2 and above.
.P
This memo describes how to write and compile programs
to can be loaded into \f5ksh\fP at run time as built-in
commands.
.AE \" abstract end
.OK Shell "Command interpreter" Language UNIX \" keyword
.MT 1 \" memo type
.H 1 INTRODUCTION
A built-in command is executed without creating a separate process.
Instead, the command is invoked as a C function by \f5ksh\fP.
If this function has no side effects in the shell process,
then the behavior of this built-in is identical to that of
the equivalent stand-alone command. The primary difference
in this case is performance. The overhead of process creation
is eliminated. For commands of short duration, the effect
can be dramatic. For example, on SUN OS 4.1, the time do
run \f5wc\fP on a small file of about 1000 bytes, runs
about 50 times faster as a built-in command.
.P
In addition, built-in commands that have side effects on the
shell environment can be written.
This is usually done to extend the application domain for
shell programming. For example, an X-windows extension
that makes heavy use of the shell variable namespace
was added as a group of built-ins commands that
are added at run time.
The result is a windowing shell that can be used to write
X-windows applications.
.P
While there are definite advantages to adding built-in
commands, there are some disadvantages as well.
Since the built-in command and \f5ksh\fP share the same
address space, a coding error in the built-in program
may affect the behavior of \f5ksh\fP; perhaps causing
it to core dump or hang.
Debugging is also more complex since your code is now
a part of a larger entity.
The isolation provided by a separate process
guarantees that all resources used by the command
will be freed when the command completes.
Also, since the address space of \f5ksh\fP will be larger,
this may increase the time it takes \f5ksh\fP to fork() and
exec() a non-builtin command.
It makes no sense to add a built-in command that takes
a long time to run or that is run only once, since the performance
benefits will be negligible.
Built-ins that have side effects in the current shell
environment have the disadvantage of increasing the
coupling between the built-in and \f5ksh\fP making
the overall system less modular and more monolithic.
.P
Despite these drawbacks, in many cases extending
\f5ksh\fP by adding built-in
commands makes sense and allows reuse of the shell
scripting ability in an application specific domain.
This memo describes how to write \f5ksh\fP extensions.
.H 1 "WRITING BUILT-IN COMMANDS"
There is a development kit available for writing \f5ksh\fP
built-ins. The development kit has three directories,
\f5include\fP, \f5lib\fP, and \f5bin\fP.
The \f5include\fP directory contains a sub-directory
named \f5ast\fP that contains interface prototypes
for functions that you can call from built-ins. The \f5lib\fP
directory contains the \fBast\fP library\*F
.FS
\fBast\fP stands for Advanced Software Technology
.FE
and a library named \fBlibcmd\fP that contains a version
of several of the standard POSIX\*(Rf
.RS
.I "POSIX \- Part 2: Shell and Utilities,"
IEEE Std 1003.2-1992, ISO/IEC 9945-2:1993.
.RF
utilities that can be made run time built-ins.
It is best to set the value of the environment variable
\fB\s-1PACKAGE_\s+1ast\fP to the pathname of the directory
containing the development kit.
Users of \f5nmake\fP\*(Rf
.RS
Glenn Fowler,
Nmake reference needed
.RF
2.3 and above will then be able to
use the rule
.nf
.in .5i
\f5:PACKAGE: ast\fP
.in
.fi
in their makefiles and not have to specify any \f5-I\fP switches
to the compiler.
.P
A built-in command has the same calling convention as
the \f5main\fP function of a program,
.nf
.in .5i
\f5int main(int argc, char *argv[])\fP.
.in
.fi
However, instead of \f5main\fP, you must use the function name
\f5b_\fP\fIname\fP, where \fIname\fP is the name
of the built-in you wish to define.
Instead of \f5exit\fP, you need to use \f5return\fP
to terminate your command.
The return value, will become the exit status of the command.
.P
The steps necessary to create and add a run time built-in are
illustrated in the following simple example.
Suppose, you wish to add a built-in command named \f5hello\fP
which requires one argument and prints the word hello followed
by its argument. First, write the following program in the file
\f5hello.c\fP:
.nf
.in .5i
\f5#include <stdio.h>
int b_hello(int argc, char *argv[])
{
if(argc != 2)
{
fprintf(stderr,"Usage: hello arg\en");
return(2);
}
printf("hello %s\en",argv[1]);
return(0);
}\fP
.in
.fi
.P
Next, the program needs to be compiled.
On some systems it is necessary to specify a compiler
option to produce position independent code
for dynamic linking.
If you do not compile with \f5nmake\fP
it is important to specify the a special include directory
when compiling built-ins.
.nf
.in .5i
\f5cc -pic -I$PACKAGE_ast/include -c hello.c\fP
.in
.fi
since the special version of \f5<stdio.h>\fP
in the development kit is required.
This command generates \f5hello.o\fP in the current
directory.
.P
On some systems, you cannot load \f5hello.o\fP directly,
you must build a shared library instead.
Unfortunately, the method for generating a shared library
differs with operating system.
In addition, if you have several built-ins, it is desirable
to build a shared library that contains them all.
The shell script named
\f5genbuiltin\fP in the development kit
calls the linker with appropriate arguments.
It is invoked as
.nf
.in .5i
\f5genbuiltin -o \fP\fIlibname objectname\fP \f5...\fP.
.in
.fi
In our example we invoke
.nf
.in .5i
\f5genbuiltin -o hello.so hello.o\fP
.in
.fi
to build a shared library named \f5hello.so\fP that can be
added to \f5ksh\fP at run time.
.P
The final step is using the built-in.
This can be done with the \f5ksh\fP command \f5builtin\fP.
To load the shared library \f5hello.so\fP and to add
the built-in \f5hello\fP, invoke the command,
.nf
.in .5i
\f5builtin -f hello.so hello\fP
.in
.fi
Once this command has been invoked, you can invoke \f5hello\fP
as you do any other command.
.P
It is often desirable to make a command \fIbuilt-in\fP
the first time that it is referenced. The first
time \f5hello\fP is invoked, \f5ksh\fP should load and execute it,
whereas for subsequent invocations \f5ksh\fP should just execute the built-in.
This can be done by creating a file named \f5hello\fP
with the following contents:
.nf
.in .5i
\f5function hello
{
unset -f hello
builtin -f hello.so hello
hello "$@"
}\fP
.in
.fi
This file \f5hello\fP needs to be placed in a directory that is
in your \fB\s-1FPATH\s+1\fP variable. In addition, the full
pathname for \f5hello.so\fP should be used in this script
so that the run time loader will be able to find this shared library
no matter where the command \f5hello\fP is invoked.
.H 1 "CODING REQUIREMENTS AND CONVENTIONS"
As mentioned above, the entry point for built-ins must be of
the form \f5b_\fP\fIname\fP.
Your built-ins can call functions from the standard C library,
the \fBast\fP library, interface functions provided by \f5ksh\fP,
and your own functions.
You should avoid using any global symbols beginning with
.BR sh_ ,
.BR nv_ ,
and
.B ed_
since these are used by \f5ksh\fP itself.
In addition, \f5#define\fP constants in \f5ksh\fP interface
files, use symbols beginning with \fBSH_\fP to that you should
avoid using names beginning with \fBSH_\fP.
.H 2 "Header Files"
The development kit provides a portable interface
to the C library and to libast.
The header files in the development kit are compatible with
K&R C\*(Rf,
.RS
Brian W. Kernighan and Dennis M. Ritchie,
.IR "The C Programming Language" ,
Prentice Hall, 1978.
.RF
ANSI-C\*(Rf,
.RS
American National Standard for Information Systems \- Programming
Language \- C, ANSI X3.159-1989.
.RF
and C++\*(Rf.
.RS
Bjarne Stroustroup,
.IR "C++" ,
Addison Wesley, xxxx
.RF
.P
The best thing to do is to include the header file \f5<shell.h>\fP.
This header file causes the \f5<ast.h>\fP header, the
\f5<error.h>\fP header and the \f5<stak.h>\fP
header to be included as well as defining prototypes
for functions that you can call to get shell
services for your builtins.
The header file \f5<ast.h>\fP
provides prototypes for many \fBlibast\fP functions
and all the symbol and function definitions from the
ANSI-C headers, \f5<stddef.h>\fP,
\f5<stdlib.h>\fP, \f5<stdarg.h>\fP, \f5<limits.h>\fP,
and \f5<string.h>\fP.
It also provides all the symbols and definitions for the
POSIX\*(Rf
.RS
.I "POSIX \- Part 1: System Application Program Interface,"
IEEE Std 1003.1-1990, ISO/IEC 9945-1:1990.
.RF
headers \f5<sys/types.h>\fP, \f5<fcntl.h>\fP, and
\f5<unistd.h>\fP.
You should include \f5<ast.h>\fP instead of one or more of
these headers.
The \f5<error.h>\fP header provides the interface to the error
and option parsing routines defined below.
The \f5<stak.h>\fP header provides the interface to the memory
allocation routines described below.
.P
Programs that want to use the information in \f5<sys/stat.h>\fP
should include the file \f5<ls.h>\fP instead.
This provides the complete POSIX interface to \f5stat()\fP
related functions even on non-POSIX systems.
.P
.H 2 "Input/Output"
\f5ksh\fP uses \fBsfio\fP,
the Safe/Fast I/O library\*(Rf,
.RS
David Korn and Kiem-Phong Vo,
.IR "SFIO - A Safe/Fast Input/Output library,"
Proceedings of the Summer Usenix,
pp. , 1991.
.RF
to perform all I/O operations.
The \fBsfio\fP library, which is part of \fBlibast\fP,
provides a superset of the functionality provided by the standard
I/O library defined in ANSI-C.
If none of the additional functionality is required,
and if you are not familiar with \fBsfio\fP and
you do not want to spend the time learning it,
then you can use \fBsfio\fP via the \fBstdio\fP library
interface. The development kit contains the header \f5<stdio.h>\fP
which maps \fBstdio\fP calls to \fBsfio\fP calls.
In most instances the mapping is done
by macros or inline functions so that there is no overhead.
The man page for the \fBsfio\fP library is in an Appendix.
.P
However, there are some very nice extensions and
performance improvements in \fBsfio\fP
and if you plan any major extensions I recommend
that you use it natively.
.H 2 "Error Handling"
For error messages it is best to use the \fBast\fP library
function \f5error()\fP rather that sending output to
\f5stderr\fP or the equivalent \f5sfstderr\fP directly.
Using \f5error()\fP will make error message appear
more uniform to the user.
Furthermore, using \f5error()\fP should make it easier
to do error message translation for other locales
in future versions of \f5ksh\fP.
.P
The first argument to \f5error()\fP contains that error type
and value. The second argument is a \fIprintf\fP style format
and the remaining arguments are arguments to be printed
as part of the message. A new-line is inserted at the
end of each message and therefore, should not appear as
part of the format string.
The first argument should be one of the following:
.VL .5i
.LI \f5ERROR_exit(\fP\fIn\fP\f5)\fP:
If \fIn\fP is not-zero, the builtin will exit value \fIn\fP after
printing the message.
.LI \f5ERROR_system(\fP\fIn\fP\f5)\fP:
Exit builtin with exit value \fIn\fP after printing the message.
The message will display the message corresponding to \f5errno\fP
enclosed within \f5[\ ]\fP at the end of the message.
.LI \f5ERROR_usage(\fP\fIn\fP\f5)\fP:
Will generate a usage message and exit. If \fIn\fP is non-zero,
the exit value will be 2. Otherwise the exit value will be 0.
.LI \f5ERROR_debug(\fP\fIn\fP\f5)\fP:
Will print a level \fIn\fP debugging message and will then continue.
.LI \f5ERROR_warn(\fP\fIn\fP\f5)\fP:
Prints a warning message. \fIn\fP is ignored.
.H 2 "Option Parsing"
The first thing that a built-in should do is to check
the arguments for correctness and to print any usage
messages on standard error.
For consistency with the rest of \f5ksh\fP, it is best
to use the \f5libast\fP functions \f5optget()\fP and
\f5optusage()\fPfor this
purpose.
The header \f5<error.h>\fP included prototypes for
these functions.
The \f5optget()\fP function is similar to the
System V C library function \f5getopt()\fP,
but provides some additional capabilities.
Built-ins that use \f5optget()\fP provide a more
consistent user interface.
.P
The \f5optget()\fP function is invoked as
.nf
.in .5i
\f5int optget(char *argv[], const char *optstring)\fP
.in
.fi
where \f5argv\fP is the argument list and \f5optstring\fP
is a string that specifies the allowable arguments and
additional information that is used to format \fIusage\fP
messages.
Like \f5getopt()\fP,
single letter options are represented by the letter itself,
and options that take a string argument are followed by the \f5:\fP
character.
Option strings have the following special characters:
.VL .5i
.LI \f5:\fP
Used after a letter option to indicate that the option
takes an option argument.
The variable \f5opt_arg\fP will point to this
value after the given argument is encountered.
.LI \f5#\fP
Used after a letter option to indicate that the option
can only take a numerical value.
The variable \f5opt_num\fP will contain this
value after the given argument is encountered.
.LI \f5?\fP
Used after a \f5:\fP or \f5#\fP (and after the optional \f5?\fP)
to indicate the the
preceding option argument is not required.
.LI \f5[\fP...\f5]\fP
After a \f5:\fP or \f5#\fP, the characters contained
inside the brackets are used to identify the option
argument when generating a \fIusage\fP message.
.LI \fIspace\fP
The remainder of the string will only be used when generating
usage messages.
.LE
.P
The \f5optget()\fP function returns the matching option letter if
one of the legal option is matched.
Otherwise, \f5optget()\fP returns
.VL .5i
.LI \f5':'\fP
If there is an error. In this case the variable \f5opt_arg\fP
contains the error string.
.LI \f50\fP
Indicates the end of options.
The variable \f5opt_ind\fP contains the number of arguments
processed.
.LI \f5'?'\fP
A usage message has been required.
You normally call \f5optusage()\fP to generate and display
the usage message.
.LE
.P
The following is an example of the option parsing portion
of the \f5wc\fP utility.
.nf
.in +5
\f5#include <shell.h>
while(1) switch(n=optget(argv,"xf:[file]"))
{
case 'f':
file = opt_arg;
break;
case ':':
error(ERROR_exit(0), opt_arg);
break;
case '?':
error(ERROR_usage(2), opt_arg);
break;
}\fP
.in
.fi
.H 2 "Storage Management"
It is important that any memory used by your built-in
be returned. Otherwise, if your built-in is called frequently,
\f5ksh\fP will eventually run out of memory.
You should avoid using \f5malloc()\fP for memory that must
be freed before returning from you built-in, because by default,
\f5ksh\fP will terminate you built-in in the event of an
interrupt and the memory will not be freed.
.P
The best way to to allocate variable sized storage is
through calls to the \fBstak\fP library
which is included in \fBlibast\fP
and which is used extensively by \f5ksh\fP itself.
Objects allocated with the \f5stakalloc()\fP
function are freed when you function completes
or aborts.
The \fBstak\fP library provides a convenient way to
build variable length strings and other objects dynamically.
The man page for the \fBstak\fP library is contained
in the Appendix.
.P
Before \f5ksh\fP calls each built-in command, it saves
the current stack location and restores it after
it returns.
It is not necessary to save and restore the stack
location in the \f5b_\fP entry function,
but you may want to write functions that use this stack
are restore it when leaving the function.
The following coding convention will do this in
an efficient manner:
.nf
.in .5i
\fIyourfunction\fP\f5()
{
char *savebase;
int saveoffset;
if(saveoffset=staktell())
savebase = stakfreeze(0);
\fP...\f5
if(saveoffset)
stakset(savebase,saveoffset);
else
stakseek(0);
}\fP
.in
.fi
.H 1 "CALLING \f5ksh\fP SERVICES"
Some of the more interesting applications are those that extend
the functionality of \f5ksh\fP in application specific directions.
A prime example of this is the X-windows extension which adds
builtins to create and delete widgets.
The \fBnval\fP library is used to interface with the shell
name space.
The \fBshell\fP library is used to access other shell services.
.H 2 "The nval library"
A great deal of power is derived from the ability to use
portions of the hierarchal variable namespace provided by \f5ksh-93\fP
and turn these names into active objects.
.P
The \fBnval\fP library is used to interface with shell
variables.
A man page for this file is provided in an Appendix.
You need to include the header \f5<nval.h>\fP
to access the functions defined in the \fBnval\fP library.
All the functions provided by the \fBnval\fP library begin
with the prefix \f5nv_\fP.
Each shell variable is an object in an associative table
that is referenced by name.
The type \f5Namval_t*\fP is pointer to a shell variable.
To operate on a shell variable, you first get a handle
to the variable with the \f5nv_open()\fP function
and then supply the handle returned as the first
argument of the function that provides an operation
on the variable.
You must call \f5nv_close()\fP when you are finished
using this handle so that the space can be freed once
the value is unset.
The two most frequent operations are to get the value of
the variable, and to assign value to the variable.
The \f5nv_getval()\fP returns a pointer the the
value of the variable.
In some cases the pointer returned is to a region that
will be overwritten by the next \f5nv_getval()\fP call
so that if the value isn't used immediately, it should
be copied.
Many variables can also generate a numeric value.
The \f5nv_getnum()\fP function returns a numeric
value for the given variable pointer, calling the
arithmetic evaluator if necessary.
.P
The \f5nv_putval()\fP function is used to assign a new
value to a given variable.
The second argument to \f5putval()\fP is the value
to be assigned
and the third argument is a \fIflag\fP which
is used in interpreting the second argument.
.P
Each shell variable can have one or more attributes.
The \f5nv_isattr()\fP is used to test for the existence
of one or more attributes.
See the appendix for a complete list of attributes.
.P
By default, each shell variable passively stores the string you
give with with \f5nv_putval()\fP, and returns the value
with \f5getval()\fP. However, it is possible to turn
any node into an active entity by assigning functions
to it that will be called whenever \f5nv_putval()\fP
and/or \f5nv_getval()\fP is called.
In fact there are up to five functions that can
associated with each variable to override the
default actions.
The type \f5Namfun_t\fP is used to define these functions.
Only those that are non-\f5NULL\fP override the
default actions.
To override the default actions, you must allocate an
instance of \f5Namfun_t\fP, and then assign
the functions that you wish to override.
The \f5putval()\fP
function is called by the \f5nv_putval()\fP function.
A \f5NULL\fP for the \fIvalue\fP argument
indicates a request to unset the variable.
The \fItype\fP argument might contain the \f5NV_INTEGER\fP
bit so you should be prepared to do a conversion if
necessary.
The \f5getval()\fP
function is called by \f5nv_getval()\fP
value and must return a string.
The \f5getnum()\fP
function is called by by the arithmetic evaluator
and must return double.
If omitted, then it will call \f5nv_getval()\fP and
convert the result to a number.
.P
The functionality of a variable can further be increased
by adding discipline functions that
can be associated with the variable.
A discipline function allows a script that uses your
variable to define functions whose name is
\fIvarname\fP\f5.\fP\fIdiscname\fP
where \fIvarname\fP is the name of the variable, and \fIdiscname\fP
is the name of the discipline.
When the user defines such a function, the \f5settrap()\fP
function will be called with the name of the discipline and
a pointer to the parse tree corresponding to the discipline
function.
The application determines when these functions are actually
executed.
By default, \f5ksh\fP defines \f5get\fP,
f5set\fP, and \f5unset\fP as discipline functions.
.P
In addition, it is possible to provide a data area that
will be passed as an argument to
each of these functions whenever any of these functions are called.
To have private data, you need to define and allocate a structure
that looks like
.nf
.in .5i
\f5struct \fIyours\fP
{
Namfun_t fun;
\fIyour_data_fields\fP;
};\fP
.in
.fi
.H 2 "The shell library"
There are several functions that are used by \f5ksh\fP itself
that can also be called from built-in commands.
The man page for these routines are in the Appendix.
.P
The \f5sh_fmtq()\fP function takes a string and returns
a string that is quoted as necessary so that it can
be used as shell input.
This function is used to implement the \f5%q\fP option
of the shell built-in \f5printf\fP command.
.P
The \f5sh_parse()\fP function returns a parse tree corresponding
to a give file stream. The tree can be executed by supplying
it as the first argument to
the \f5sh_trap()\fP function and giving a value of \f51\fP as the
second argument.
Alternatively, the \f5sh_trap()\fP function can parse and execute
a string by passing the string as the first argument and giving \f50\fP
as the second argument.
.P
The \f5sh_isoption()\fP function can be used to set to see whether one
or more of the option settings is enabled.

View File

@@ -0,0 +1,109 @@
/* $XConsortium: aliases.c /main/3 1995/11/01 16:31:38 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <signal.h>
#include "FEATURE/options"
#include "FEATURE/dynamic"
#include "shtable.h"
#include "name.h"
/*
* This is the table of built-in aliases. These should be exported.
*/
const struct shtable2 shtab_aliases[] =
{
#ifdef SHOPT_FS_3D
"2d", NV_NOFREE|NV_EXPORT, "set -f;_2d",
#endif /* SHOPT_FS_3D */
"autoload", NV_NOFREE|NV_EXPORT, "typeset -fu",
"command", NV_NOFREE|NV_EXPORT, "command ",
"fc", NV_NOFREE|NV_EXPORT, "hist",
"float", NV_NOFREE|NV_EXPORT, "typeset -E",
"functions", NV_NOFREE|NV_EXPORT, "typeset -f",
"hash", NV_NOFREE|NV_EXPORT, "alias -t --",
"history", NV_NOFREE|NV_EXPORT, "hist -l",
"integer", NV_NOFREE|NV_EXPORT, "typeset -i",
"nameref", NV_NOFREE|NV_EXPORT, "typeset -n",
"nohup", NV_NOFREE|NV_EXPORT, "nohup ",
"r", NV_NOFREE|NV_EXPORT, "hist -s",
"redirect", NV_NOFREE|NV_EXPORT, "command exec",
"times", NV_NOFREE|NV_EXPORT, "{ { time;} 2>&1;}",
"type", NV_NOFREE|NV_EXPORT, "whence -v",
#ifdef SIGTSTP
"stop", NV_NOFREE|NV_EXPORT, "kill -s STOP",
"suspend", NV_NOFREE|NV_EXPORT, "kill -s STOP $$",
#endif /*SIGTSTP */
"", 0, (char*)0
};

View File

@@ -0,0 +1,259 @@
/* $XConsortium: builtins.c /main/3 1995/11/01 16:31:54 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define mount _AST_mount
#include <shell.h>
#include <signal.h>
#include "shtable.h"
#include "name.h"
#ifdef KSHELL
# include "builtins.h"
# include "jobs.h"
# include "FEATURE/cmds"
#if defined(__STDC__) || defined(__STDPP__)
# define bltin(x) (b_##x)
#else
# define bltin(x) (b_/**/x)
#endif
#else
# define bltin(x) 0
#endif
/*
* The order up through "[" is significant
*/
const struct shtable3 shtab_builtins[] =
{
"login", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(login),
"exec", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(exec),
"set", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(set),
":", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(true),
"true", NV_BLTIN|BLT_ENV, bltin(true),
"command", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(command),
"cd", NV_BLTIN|BLT_ENV, bltin(cd),
"break", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(brk_cont),
"continue", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(brk_cont),
"typeset", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(typeset),
"test", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(test),
"[", NV_BLTIN|BLT_ENV, bltin(test),
#ifdef _bin_newgrp
"newgrp", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(login),
#endif /* _bin_newgrp */
".", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(dot_cmd),
"alias", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
"hash", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(alias),
"exit", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(ret_exit),
"export", NV_BLTIN|BLT_SPC|BLT_DCL, bltin(read_export),
"eval", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_EXIT,bltin(eval),
"fc", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
"hist", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(hist),
"readonly", NV_BLTIN|BLT_ENV|BLT_SPC|BLT_DCL,bltin(read_export),
"return", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(ret_exit),
"shift", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(shift),
"trap", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(trap),
"unalias", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unalias),
"unset", NV_BLTIN|BLT_ENV|BLT_SPC, bltin(unset),
"builtin", NV_BLTIN, bltin(builtin),
#ifdef SHOPT_ECHOPRINT
"echo", NV_BLTIN|BLT_ENV, bltin(print),
#else
"echo", NV_BLTIN|BLT_ENV, bltin(echo),
#endif /* SHOPT_ECHOPRINT */
#ifdef JOBS
# ifdef SIGTSTP
"bg", NV_BLTIN|BLT_ENV, bltin(bg_fg),
"fg", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(bg_fg),
"disown", NV_BLTIN|BLT_ENV, bltin(bg_fg),
"kill", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(kill),
# else
"/bin/kill", NV_BLTIN|BLT_ENV|NV_NOFREE, bltin(kill),
# endif /* SIGTSTP */
"jobs", NV_BLTIN|BLT_ENV, bltin(jobs),
#endif /* JOBS */
"false", NV_BLTIN|BLT_ENV, bltin(false),
"getconf", NV_BLTIN|BLT_ENV, bltin(getconf),
"getopts", NV_BLTIN|BLT_ENV, bltin(getopts),
"let", NV_BLTIN|BLT_ENV, bltin(let),
"print", NV_BLTIN|BLT_ENV, bltin(print),
"printf", NV_BLTIN|NV_NOFREE, bltin(printf),
"pwd", NV_BLTIN|NV_NOFREE, bltin(pwd),
"read", NV_BLTIN|BLT_ENV, bltin(read),
"sleep", NV_BLTIN|NV_NOFREE, bltin(sleep),
"alarm", NV_BLTIN, bltin(alarm),
"ulimit", NV_BLTIN|BLT_ENV, bltin(ulimit),
"umask", NV_BLTIN|BLT_ENV, bltin(umask),
#ifdef _cmd_universe
"universe", NV_BLTIN|BLT_ENV, bltin(universe),
#endif /* _cmd_universe */
#ifdef SHOPT_FS_3D
"vpath", NV_BLTIN|BLT_ENV, bltin(vpath_map),
"vmap", NV_BLTIN|BLT_ENV, bltin(vpath_map),
#endif /* SHOPT_FS_3D */
"wait", NV_BLTIN|BLT_ENV|BLT_EXIT, bltin(wait),
"type", NV_BLTIN|BLT_ENV, bltin(whence),
"whence", NV_BLTIN|BLT_ENV, bltin(whence),
#ifdef apollo
"inlib", NV_BLTIN|BLT_ENV, bltin(inlib),
"rootnode", NV_BLTIN, bltin(rootnode),
"ver", NV_BLTIN, bltin(ver),
#endif /* apollo */
"/bin/basename",NV_BLTIN|NV_NOFREE, bltin(basename),
"/bin/chmod", NV_BLTIN|NV_NOFREE, bltin(chmod),
"/bin/dirname", NV_BLTIN|NV_NOFREE, bltin(dirname),
"/bin/head", NV_BLTIN|NV_NOFREE, bltin(head),
"/bin/mkdir", NV_BLTIN|NV_NOFREE, bltin(mkdir),
#if defined(_usr_bin_logname) && !defined(_bin_logname)
"/usr/bin/logname", NV_BLTIN|NV_NOFREE, bltin(logname),
#else
"/bin/logname", NV_BLTIN|NV_NOFREE, bltin(logname),
#endif
"/bin/cat", NV_BLTIN|NV_NOFREE, bltin(cat),
"/bin/cmp", NV_BLTIN|NV_NOFREE, bltin(cmp),
#if defined(_usr_bin_cut) && !defined(_bin_cut)
"/usr/bin/cut", NV_BLTIN|NV_NOFREE, bltin(cut),
#else
"/bin/cut", NV_BLTIN|NV_NOFREE, bltin(cut),
#endif
"/bin/uname", NV_BLTIN|NV_NOFREE, bltin(uname),
#if defined(_usr_bin_wc) && !defined(_bin_wc)
"/usr/bin/wc", NV_BLTIN|NV_NOFREE, bltin(wc),
#else
# if defined(_usr_ucb_wc) && !defined(_bin_wc)
"/usr/ucb/wc", NV_BLTIN|NV_NOFREE, bltin(wc),
# else
"/bin/wc", NV_BLTIN|NV_NOFREE, bltin(wc),
# endif
#endif
"", 0, 0
};
const char sh_optalarm[] = "r [varname seconds]";
const char sh_optalias[] = "ptx [name=[value]...]";
const char sh_optbuiltin[] = "dsf:[library] [name...]";
const char sh_optcd[] = "LP [dir] [change]";
const char sh_optcflow[] = " [n]";
const char sh_optcommand[] = "pvV name [arg]...";
const char sh_optdot[] = " name [arg...]";
#ifndef ECHOPRINT
const char sh_optecho[] = " [-n] [arg...]";
#endif /* !ECHOPRINT */
const char sh_opteval[] = " [arg...]";
const char sh_optexec[] = "a:[name]c [command [args...] ]";
const char sh_optexport[] = "p [name[=value]...]";
const char sh_optgetopts[] = ":a:[name] optstring name [args...]";
const char sh_optgetconf[] = " [name [pathname] ]";
const char sh_optjoblist[] = " [job...]";
const char sh_opthist[] = "e:[editor]lnrsN# [first] [last]";
const char sh_optjobs[] = "nlp [job...]";
const char sh_optkill[] = "ln#[signum]s:[signame] sig...";
const char sh_optlet[] = " expr...";
const char sh_optprint[] = "f:[format]enprsu:[filenum] [arg...]";
const char sh_optprintf[] = " format [arg...]";
const char sh_optpwd[] = "LP";
const char sh_optread[] = "Ad:[delim]prst#[timeout]u#[filenum] [name...]";
#ifdef SHOPT_KIA
const char sh_optksh[] = "+DircabefhkmnpstuvxCR:[file]o:?[option] [arg...]";
const char sh_optset[] = "+abefhkmnpstuvxCR:[file]o:?[option]A:[name] [arg...]";
#else
const char sh_optksh[] = "+DircabefhkmnpstuvxCo:?[option] [arg...]";
const char sh_optset[] = "+abefhkmnpstuvxCo:?[option]A:[name] [arg...]";
#endif /* SHOPT_KIA */
const char sh_optsleep[] = " seconds";
const char sh_opttrap[] = "p [action condition...]";
#ifdef SHOPT_OO
const char sh_opttypeset[] = "+AC:E#?F#?H:[name]L#?R#?Z#?fi#?[base]lnprtux [name=[value]...]";
#else
const char sh_opttypeset[] = "+AE#?F#?HL#?R#?Z#?fi#?[base]lnprtux [name=[value]...]";
#endif /* SHOPT_OO */
const char sh_optulimit[] = "HSacdfmnstv [limit]";
const char sh_optumask[] = "S [mask]";
const char sh_optuniverse[] = " [name]";
const char sh_optunset[] = "fnv name...";
const char sh_optunalias[] = "a name...";
#ifdef SHOPT_FS_3D
const char sh_optvpath[] = " [top] [base]";
const char sh_optvmap[] = " [dir] [list]";
#endif /* SHOPT_FS_3D */
const char sh_optwhence[] = "afpv name...";
const char e_alrm1[] = "alarm -r %s +%.3g\n";
const char e_alrm2[] = "alarm %s %.3f\n";
const char e_badfun[] = "%s: illegal function name";
const char e_baddisc[] = "%s: invalid discipline function";
const char e_nospace[] = "out of memory";
const char e_nofork[] = "cannot fork";
const char e_nosignal[] = "%s: unknown signal name";
const char e_numeric[] = "*([0-9])?(.)*([0-9])";
const char e_condition[] = "condition(s) required";
const char e_cneedsarg[] = "-c requires argument";

View File

@@ -0,0 +1,267 @@
/* $XConsortium: config.c /main/3 1995/11/01 16:32:07 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include "FEATURE/options"
#include "shtable.h"
#define value(n,type) ((((unsigned)n)<<2)|(type))
const Shtable_t shtab_config[] =
{
#ifdef _SC_ARG_MAX
"ARG_MAX", value(_SC_ARG_MAX,2),
#else
"ARG_MAX", value(1,0),
#endif /* _SC_ARG_MAX */
#ifdef _SC_BC_BASE_MAX
"BC_BASE_MAX", value(_SC_BC_BASE_MAX,2),
#else
"BC_BASE_MAX", value(1,0),
#endif /* _SC_BC_BASE_MAX */
#ifdef _SC_BC_DIM_MAX
"BC_DIM_MAX", value(_SC_BC_DIM_MAX,2),
#else
"BC_DIM_MAX", value(1,0),
#endif /* _SC_BC_DIM_MAX */
#ifdef _SC_BC_SCALE_MAX
"BC_SCALE_MAX", value(_SC_BC_SCALE_MAX,2),
#else
"BC_SCALE_MAX", value(1,0),
#endif /* _SC_BC_SCALE_MAX */
#ifdef _SC_BC_STRING_MAX
"BC_STRING_MAX", value(_SC_BC_STRING_MAX,2),
#else
"BC_STRING_MAX", value(1,0),
#endif /* _SC_BC_BASE_MAX */
#ifdef _SC_CHILD_MAX
"CHILD_MAX", value(_SC_CHILD_MAX,2),
#else
"CHILD_MAX", value(1,0),
#endif /* _SC_CHILD_MAX */
#ifdef _SC_LINE_MAX
"LINE_MAX", value(_SC_LINE_MAX,2),
#else
"LINE_MAX", value(1,0),
#endif /* _SC_LINE_MAX */
#ifdef _PC_LINK_MAX
"LINK_MAX", value(_PC_LINK_MAX,3),
#else
"LINK_MAX", value(1,0),
#endif /* _PC_LINK_MAX */
#ifdef _PC_MAX_CANON
"MAX_CANON", value(_PC_MAX_CANON,3),
#else
"MAX_CANON", value(1,0),
#endif /* _PC_MAX_CANON */
#ifdef _PC_MAX_INPUT
"MAX_INPUT", value(_PC_MAX_INPUT,3),
#else
"MAX_INPUT", value(1,0),
#endif /* _PC_MAX_INPUT */
#ifdef _PC_NAME_MAX
"NAME_MAX", value(_PC_NAME_MAX,3),
#else
"NAME_MAX", value(1,0),
#endif /* _PC_NAME_MAX */
#ifdef _SC_CLK_TCK
"CLK_TCK", value(_SC_CLK_TCK,2),
#else
"CLK_TCK", value(1,0),
#endif /* _SC_CLK_TCK */
#ifdef _SC_COLL_WEIGHTS_MAX
"COLL_WEIGHTS_MAX", value(_SC_COLL_WEIGHTS_MAX,2),
#else
"COLL_WEIGHTS_MAX", value(1,0),
#endif /* _SC_COLL_WEIGHTS_MAX */
#ifdef _SC_EXPR_NEST_MAX
"EXPR_NEST_MAX", value(_SC_EXPR_NEST_MAX,2),
#else
"EXPR_NEST_MAX", value(1,0),
#endif /* _SC_EXPR_NEST_MAX */
#ifdef _SC_NGROUPS_MAX
"NGROUPS_MAX", value(_SC_NGROUPS_MAX,2),
#else
"NGROUPS_MAX", value(1,0),
#endif /* _SC_NGROUPS_MAX */
#ifdef _SC_OPEN_MAX
"OPEN_MAX", value(_SC_OPEN_MAX,2),
#else
"OPEN_MAX", value(1,0),
#endif /* _SC_OPEN_MAX */
#ifdef _CS_PATH
"PATH", value(_CS_PATH,1),
#else
"PATH", value(1,0),
#endif /* _SC_PATH */
#ifdef _PC_PATH_MAX
"PATH_MAX", value(_PC_PATH_MAX,3),
#else
"PATH_MAX", value(1,0),
#endif /* _PC_PATH_MAX */
#ifdef _PC_PIPE_BUF
"PIPE_BUF", value(_PC_PIPE_BUF,3),
#else
"PIPE_BUF", value(1,0),
#endif /* _PC_PIPE_BUF */
#ifdef _SC_2_C_BIND
"POSIX2_C_BIND", value(_SC_2_C_BIND,2),
#else
"POSIX2_C_BIND", value(1,0),
#endif /* _SC_C_BIND */
#ifdef _SC_2_C_DEV
"POSIX2_C_DEV", value(_SC_2_C_DEV,2),
#else
"POSIX2_C_DEV", value(1,0),
#endif /* _SC_C_DEV */
#ifdef _SC_2_FORT_DEV
"POSIX2_FORT_DEV", value(_SC_2_FORT_DEV,2),
#else
"POSIX2_FORT_DEV", value(1,0),
#endif /* _SC_FORT_DEV */
#ifdef _SC_2_FORT_RUN
"POSIX2_FORT_RUN", value(_SC_2_FORT_RUN,2),
#else
"POSIX2_FORT_RUN", value(1,0),
#endif /* _SC_FORT_RUN */
#ifdef _SC_2_CHAR_TERM
"POSIX2_CHAR_TERM", value(_SC_2_CHAR_TERM,2),
#else
"POSIX2_CHAR_TERM", value(1,0),
#endif /* _SC_CHAR_TERM */
#ifdef _SC_2_LOCALDEF
"POSIX2_LOCALDEF", value(_SC_2_LOCALDEF,2),
#else
"POSIX2_LOCALDEF", value(1,0),
#endif /* _SC_LOCALDEF */
#ifdef _SC_2_SW_DEV
"POSIX2_SW_DEV", value(_SC_2_SW_DEV,2),
#else
"POSIX2_SW_DEV", value(1,0),
#endif /* _SC_SW_DEV */
#ifdef _SC_2_UPE
"POSIX2_UPE", value(_SC_2_UPE,2),
#else
"POSIX2_UPE", value(1,0),
#endif /* _SC_UPE */
#ifdef _SC_2_VERSION
"POSIX2_VERSION", value(_SC_2_VERSION,2),
#else
"POSIX2_VERSION", value(1,0),
#endif /* _SC_VERSION */
#ifdef _SC_RE_DUP_MAX
"RE_DUP_MAX", value(_SC_RE_DUP_MAX,2),
#else
"RE_DUP_MAX", value(1,0),
#endif /* _SC_RE_DUP_MAX */
#ifdef _SC_STREAM_MAX
"STREAM_MAX", value(_SC_STREAM_MAX,2),
#else
"STREAM_MAX", value(1,0),
#endif /* _SC_STREAM_MAX */
#ifdef _SC_TZNAME_MAX
"TZNAME_MAX", value(_SC_TZNAME_MAX,2),
#else
"TZNAME_MAX", value(1,0),
#endif /* _SC_TZNAME_MAX */
#ifdef _SC_JOB_CONTROL
"_POSIX_JOB_CONTROL", value(_SC_JOB_CONTROL,2),
#else
"_POSIX_JOB_CONTROL", value(1,0),
#endif /* _SC_JOB_CONTROL */
#ifdef _PC_CHOWN_RESTRICTED
"_POSIX_CHOWN_RESTRICTED", value(_PC_CHOWN_RESTRICTED,3),
#else
"_POSIX_CHOWN_RESTRICTED", value(1,0),
#endif /* _PC_CHOWN_RESTRICTED */
#ifdef _PC_NO_TRUNC
"_POSIX_NO_TRUNC", value(_PC_NO_TRUNC,3),
#else
"_POSIX_NO_TRUNC", value(1,0),
#endif /* _PC_NO_TRUNC */
#ifdef _SC_SAVED_IDS
"_POSIX_SAVED_IDS", value(_SC_SAVED_IDS,2),
#else
"_POSIX_SAVED_IDS", value(1,0),
#endif /* _SC_SAVED_IDS */
#ifdef _PC_VDISABLE
"_POSIX_VDISABLE", value(_PC_VDISABLE,3),
#else
"_POSIX_VDISABLE", value(1,0),
#endif /* _PC_VDISABLE */
#ifdef _SC_VERSION
"_POSIX_VERSION", value(_SC_VERSION,2),
#else
"_POSIX_VERSION", value(1,0),
#endif /* _SC_VERSION */
"", 0
};

View File

@@ -0,0 +1,112 @@
/* $XConsortium: keywords.c /main/3 1995/11/01 16:32:23 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <hash.h>
#include "shtable.h"
#include "shlex.h"
#include "FEATURE/options"
/*
* table of reserved words in shell language
* This list must be in in ascii sorted order
*/
const Shtable_t shtab_reserved[] =
{
"!", NOTSYM,
"[[", BTESTSYM,
"case", CASESYM,
"do", DOSYM,
"done", DONESYM,
"elif", ELIFSYM,
"else", ELSESYM,
"esac", ESACSYM,
"fi", FISYM,
"for", FORSYM,
"function", FUNCTSYM,
"if", IFSYM,
"in", INSYM,
"select", SELECTSYM,
"then", THENSYM,
"time", TIMESYM,
"until", UNTILSYM,
"while", WHILESYM,
"{", LBRACE,
"}", RBRACE,
"", 0,
};
const char e_unexpected[] = "unexpected";
const char e_unmatched[] = "unmatched";
const char e_endoffile[] = "end of file";
const char e_newline[] = "newline";

View File

@@ -0,0 +1,455 @@
/* $XConsortium: lexstates.c /main/3 1995/11/01 16:32:39 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "FEATURE/options"
#include "lexstates.h"
/*
* This is the initial state for tokens
*/
static const char sh_lexstate0[256] =
{
S_EOF, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
#ifdef SHOPT_CRNL
S_REG, 0, S_NLTOK,S_REG, S_REG, 0, S_REG, S_REG,
#else
S_REG, 0, S_NLTOK,S_REG, S_REG, S_REG, S_REG, S_REG,
#endif /* SHOPT_CRNL */
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
0, S_REG, S_REG, S_COM, S_REG, S_REG, S_OP, S_REG,
S_OP, S_OP, S_REG, S_REG, S_REG, S_REG, S_NAME, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_OP, S_OP, S_REG, S_OP, S_REG,
S_REG, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
S_NAME, S_NAME, S_NAME, S_REG, S_REG, S_REG, S_REG, S_NAME,
S_REG, S_NAME, S_NAME, S_RES, S_RES, S_RES, S_RES, S_NAME,
S_NAME, S_RES, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME, S_NAME,
S_NAME, S_NAME, S_NAME, S_RES, S_RES, S_RES, S_NAME, S_RES,
S_NAME, S_NAME, S_NAME, S_REG, S_OP, S_REG, S_TILDE,S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
};
/*
* This state is for identifiers
*/
static const char sh_lexstate1[256] =
{
S_EOF, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
#ifdef SHOPT_CRNL
S_REG, S_BREAK,S_BREAK,S_REG, S_REG, S_BREAK,S_REG, S_REG,
#else
S_REG, S_BREAK,S_BREAK,S_REG, S_REG, S_REG, S_REG, S_REG,
#endif /* SHOPT_CRNL */
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_BREAK,S_EPAT, S_QUOTE,S_REG, S_DOL, S_REG, S_BREAK,S_LIT,
S_BREAK,S_BREAK,S_PAT, S_EPAT, S_REG, S_REG, S_DOT, S_REG,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_LABEL,S_BREAK,S_BREAK,S_EQ, S_BREAK,S_PAT,
S_EPAT, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACT,S_ESC, S_REG, S_REG, 0,
S_GRAVE,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACE,S_BREAK,S_BRACE,S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG, S_REG,
};
static const char sh_lexstate2[256] =
{
S_EOF, 0, 0, 0, 0, 0, 0, 0,
#ifdef SHOPT_CRNL
0, S_BREAK,S_BREAK,0, 0, S_BREAK,0, 0,
#else
0, S_BREAK,S_BREAK,0, 0, 0, 0, 0,
#endif /* SHOPT_CRNL */
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
S_BREAK,S_EPAT, S_QUOTE,0, S_DOL, 0, S_BREAK,S_LIT,
S_BREAK,S_BREAK,S_PAT, S_EPAT, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_COLON,S_BREAK,S_BREAK,0, S_BREAK,S_PAT,
S_EPAT, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_PAT, S_ESC, 0, 0, 0,
S_GRAVE,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACE,S_BREAK,S_BRACE,0, 0,
};
/*
* for skipping over '...'
*/
static const char sh_lexstate3[256] =
{
S_EOF, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_NL, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, S_LIT,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, S_ESC2, 0, 0, 0
};
/*
* for skipping over "..." and `...`
*/
static const char sh_lexstate4[256] =
{
S_EOF, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_NL, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_QUOTE,0, S_DOL, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, S_ESC, 0, 0, 0,
S_GRAVE,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, S_RBRA, 0, 0
};
/*
* for skipping over ?(...), [...]
*/
static const char sh_lexstate5[256] =
{
S_EOF, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_NL, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_QUOTE,0, S_DOL, 0, S_META, S_LIT,
S_PUSH, S_POP, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_POP, S_META, 0, S_META, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACT,S_ESC, S_POP, 0, 0,
S_GRAVE,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, S_META, S_POP, 0, 0
};
/*
* Defines valid expansion characters
*/
static const char sh_lexstate6[256] =
{
S_EOF, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_SPC1, S_ERR, S_SPC1, S_SPC2, S_ERR, S_ERR, S_LIT,
#ifdef SHOPT_OO
S_PAR, S_ERR, S_SPC2, S_ERR, S_ERR, S_SPC1, S_ALP, S_ERR,
#else
S_PAR, S_ERR, S_SPC2, S_ERR, S_ERR, S_SPC2, S_ALP, S_ERR,
#endif /* SHOPT_OO */
S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG,
S_DIG, S_DIG, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_SPC2,
S_SPC2, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_ERR, S_ERR, S_ERR, S_ERR, S_ALP,
S_ERR, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP, S_ALP,
S_ALP, S_ALP, S_ALP, S_LBRA, S_ERR, S_RBRA, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
};
/*
* for skipping over ${...} until modifier
*/
static const char sh_lexstate7[256] =
{
S_EOF, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_MOD2, S_ERR, S_MOD2, S_ERR, S_ERR,
S_ERR, S_ERR, S_MOD1, S_MOD1, S_ERR, S_MOD1, S_DOT, S_MOD2,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_MOD1, S_ERR, S_ERR, S_MOD1, S_ERR, S_MOD1,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACT,S_ESC, S_ERR, S_ERR, 0,
S_ERR, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_ERR, S_ERR, S_POP, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
};
/*
* This state is for $name
*/
static const char sh_lexstate8[256] =
{
S_EOF, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, 0,
S_EDOL,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL, S_EDOL,
};
/*
* This is used for macro expansion
*/
static const char sh_lexstate9[256] =
{
S_EOF, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, S_QUOTE,0, S_DOL, 0, S_PAT, S_LIT,
S_PAT, S_PAT, S_PAT, 0, 0, 0, 0, S_SLASH,
0, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG, S_DIG,
S_DIG, S_DIG, S_COLON,0, 0, S_EQ, 0, S_PAT,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, S_BRACT,S_ESC, S_ENDCH,0, 0,
S_GRAVE,0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
#ifdef SHOPT_BRACEPAT
0, 0, 0, S_PAT, S_PAT, S_ENDCH,0, 0
#else
0, 0, 0, 0, S_PAT, S_ENDCH,0, 0
#endif /* SHOPT_BRACEPAT */
};
const char *sh_lexrstates[ST_NONE] =
{
sh_lexstate0, sh_lexstate1, sh_lexstate2, sh_lexstate3,
sh_lexstate4, sh_lexstate5, sh_lexstate6, sh_lexstate7,
sh_lexstate8, sh_lexstate9, sh_lexstate5
};
const char e_lexversion[] = "%d: invalid binary script version";
const char e_lexspace[] = "line %d: use space or tab to separate operators %c and %c";
const char e_lexslash[] = "line %d: $ not preceeded by \\";
const char e_lexsyntax1[] = "syntax error at line %d: `%s' %s";
const char e_lexsyntax2[] = "syntax error: `%s' %s";
const char e_lexsyntax3[] = "syntax error at line %d: duplicate label %s";
const char e_lexlabignore[] = "line %d: label %s ignored";
const char e_lexlabunknown[] = "line %d: %s unknown label";
const char e_lexobsolete1[] = "line %d: `...` obsolete, use $(...)";
const char e_lexobsolete2[] = "line %d: -a obsolete, use -e";
const char e_lexobsolete3[] = "line %d: '=' obsolete, use '=='";
const char e_lexobsolete4[] = "line %d: %s within [[...]] obsolete, use ((...))";
const char e_lexobsolete5[] = "line %d: set %s obsolete";
const char e_lexobsolete6[] = "line %d: `{' instead of `in' is obsolete";
const char e_lexusebrace[] = "line %d: use braces to avoid ambiguities with $id[...]";
const char e_lexusequote[] = "line %d: %c within ${} should be quoted";
const char e_lexescape[] = "line %d: escape %c to avoid ambiguities";
const char e_lexquote[] = "line %d: quote %c to avoid ambiguities";
const char e_lexnested[] = "line %d: spaces required for nested subshell";
const char e_lexbadchar[] = "%c: invalid character in expression - %s";
const char e_lexfuture[] = "line %d: \\ in front of %c reserved for future use";
const char e_lexlongquote[] = "line %d: %c quote may be missing";
const char e_lexzerobyte[] = "zero byte";

View File

@@ -0,0 +1,102 @@
/* $XConsortium: limits.c /main/3 1995/11/01 16:32:55 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include "ulimit.h"
#define size_resource(a,b) ((a)|((b)<<11))
/*
* This is the list of resouce limits controlled by ulimit
* This command requires getrlimit(), vlimit(), or ulimit()
*/
#ifndef _no_ulimit
const Shtable_t shtab_limits[] =
{
{"time(seconds) ", size_resource(1,RLIMIT_CPU)},
# ifdef RLIMIT_FSIZE
{"file(blocks) ", size_resource(512,RLIMIT_FSIZE)},
# else
{"file(blocks) ", size_resource(1,2)},
# endif /* RLIMIT_FSIZE */
{"data(kbytes) ", size_resource(1024,RLIMIT_DATA)},
{"stack(kbytes) ", size_resource(1024,RLIMIT_STACK)},
{"memory(kbytes) ", size_resource(1024,RLIMIT_RSS)},
{"coredump(blocks) ", size_resource(512,RLIMIT_CORE)},
{"nofiles(descriptors)", size_resource(1,RLIMIT_NOFILE)},
{"vmemory(kbytes) ", size_resource(1024,RLIMIT_VMEM)}
};
const char e_unlimited[] = "unlimited";
#endif

View File

@@ -0,0 +1,234 @@
/* $XConsortium: msg.c /main/3 1995/11/01 16:33:09 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <errno.h>
#include "defs.h"
#include "path.h"
#include "io.h"
#include "shlex.h"
#include "timeout.h"
#include "history.h"
#include "builtins.h"
#include "jobs.h"
#include "edit.h"
#include "national.h"
#ifdef SHOPT_MULTIBYTE
const char e_version[] = "\n@(#)Version M-12/28/93d\0\n";
#else
const char e_version[] = "\n@(#)Version 12/28/93d\0\n";
#endif /* SHOPT_MULTIBYTE */
/* error messages */
const char e_timewarn[] = "\r\n\007shell will timeout in 60 seconds due to inactivity";
const char e_runvi[] = "\\hist -e \"${VISUAL:-${EDITOR:-vi}}\" ";
const char e_timeout[] = "timed out waiting for input";
const char e_mailmsg[] = "you have mail in $_";
const char e_query[] = "no query process";
const char e_history[] = "no history file";
const char e_histopen[] = "history file cannot open";
const char e_option[] = "%s: bad option(s)";
const char e_toomany[] = "open file limit exceeded";
const char e_argexp[] = "argument expected";
const char e_argtype[] = "invalid argument of type %c";
const char e_formspec[] = "%c: unknown format specifier";
const char e_badregexp[] = "%s: invalid regular expression";
const char e_number[] = "%s: bad number";
const char e_badlocale[] = "%s: unknown locale";
const char e_nullset[] = "%s: parameter null or not set";
const char e_notset[] = "%s: parameter not set";
const char e_noparent[] = "%s: no parent";
const char e_subst[] = "%s: bad substitution";
const char e_create[] = "%s: cannot create";
const char e_tmpcreate[] = "cannot create tempory file";
const char e_restricted[] = "%s: restricted";
const char e_pexists[] = "process already exists";
const char e_exists[] = "%s: file already exists";
const char e_pipe[] = "cannot create pipe";
const char e_alarm[] = "cannot set alarm";
const char e_open[] = "%s: cannot open";
const char e_logout[] = "Use 'exit' to terminate this shell";
const char e_exec[] = "%s: cannot execute";
const char e_pwd[] = "cannot access parent directories";
const char e_found[] = "%s: not found";
const char e_subscript[] = "%s: subscript out of range";
const char e_toodeep[] = "%s: recursion too deep";
const char e_access[] = "permission denied";
#ifdef _cmd_universe
const char e_nouniverse[] = "universe not accessible";
#endif /* _cmd_universe */
const char e_direct[] = "bad directory";
const char e_file[] = "%s: bad file unit number";
const char e_trap[] = "%s: bad trap";
const char e_readonly[] = "%s: is read only";
const char e_badfield[] = "%d: negative field size";
const char e_ident[] = "%s: is not an identifier";
const char e_badname[] = "%s: invalid name";
const char e_varname[] = "%s: invalid variable name";
const char e_funname[] = "%s: invalid function name";
const char e_aliname[] = "%s: invalid alias name";
const char e_badexport[] = "%s: invalid export name";
const char e_badref[] = "%s: reference variable cannot be an array";
const char e_noref[] = "%s: no reference name";
const char e_selfref[] = "%s: invalid self reference";
const char e_noalias[] = "%s: alias not found\n";
const char e_format[] = "%s: bad format";
const char e_nolabels[] = "%s: label not implemented";
const char e_notimp[] = "%s: not implemented";
const char e_nosupport[] = "not supported";
const char e_badrange[] = "%d-%d: invalid range";
const char e_needspath[] = "%s: requires pathname argument";
const char e_eneedsarg[] = "-e - requires single argument";
const char e_badconf[] = "%s: fails %s";
const char e_badbase[] = "%s unknown base";
const char e_loop[] = "%s: would cause loop";
const char e_overlimit[] = "%s: limit exceeded";
const char e_badsyntax[] = "incorrect syntax";
const char e_badwrite[] = "write to %d failed";
const char e_on [] = "on";
const char e_off[] = "off";
const char is_reserved[] = " is a keyword";
const char is_builtin[] = " is a shell builtin";
const char is_builtver[] = "is a shell builtin version of";
const char is_alias[] = "%s is an alias for ";
const char is_xalias[] = "%s is an exported alias for ";
const char is_talias[] = "is a tracked alias for";
const char is_function[] = " is a function";
const char is_xfunction[] = " is an exported function";
const char is_ufunction[] = " is an undefined function";
#ifdef JOBS
# ifdef SIGTSTP
const char e_newtty[] = "Switching to new tty driver...";
const char e_oldtty[] = "Reverting to old tty driver...";
const char e_no_start[] = "Cannot start job control";
# endif /*SIGTSTP */
const char e_no_jctl[] = "No job control";
const char e_terminate[] = "You have stopped jobs";
const char e_done[] = " Done";
const char e_nlspace[] = "\n ";
const char e_running[] = " Running";
const char e_ambiguous[] = "%s: Ambiguous";
const char e_jobsrunning[] = "You have running jobs";
const char e_no_job[] = "no such job";
const char e_no_proc[] = "no such process";
const char e_jobusage[] = "%s: Arguments must be %job or process ids";
const char e_kill[] = "kill";
#endif /* JOBS */
const char e_coredump[] = "(coredump)";
const char e_alphanum[] = "[_[:alpha:]]*([_[:alnum:]])";
#ifdef SHOPT_VPIX
const char e_vpix[] = "/vpix";
const char e_vpixdir[] = "/usr/bin";
#endif /* SHOPT_VPIX */
const char e_devfdNN[] = "/dev/fd/+([0-9])";
#ifdef apollo
const char e_rootnode[] = "Bad root node specification";
const char e_nover[] = "Version not defined";
const char e_badver[] = "Unrecognized version";
#endif /* apollo */
#ifdef SHOPT_FS_3D
const char e_cantget[] = "cannot get %s";
const char e_cantset[] = "cannot set %s";
const char e_mapping[] = "mapping";
const char e_versions[] = "versions";
#endif /* SHOPT_FS_3D */
/* string constants */
const char e_heading[] = "Current option settings";
const char e_sptbnl[] = " \t\n";
const char e_defpath[] = "/bin:/usr/bin:";
const char e_defedit[] = "/bin/ed";
const char e_unknown [] = "<command unknown>";
const char e_devnull[] = "/dev/null";
const char e_traceprompt[] = "+ ";
const char e_supprompt[] = "# ";
const char e_stdprompt[] = "$ ";
const char e_profile[] = "${HOME:-.}/.profile";
const char e_sysprofile[] = PROFILEPATH;
const char e_suidprofile[] = SUIDPROFILEPATH;
const char e_crondir[] = "/usr/spool/cron/atjobs";
const char e_prohibited[] = "login setuid/setgid shells prohibited";
#ifdef SHOPT_SUID_EXEC
const char e_suidexec[] = SUIDEXECPATH;
#endif /* SHOPT_SUID_EXEC */
const char hist_fname[] = "/.sh_history";
const char e_dot[] = ".";
const char e_envmarker[] = "A__z";
const char e_real[] = "\nreal";
const char e_user[] = "user";
const char e_sys[] = "sys";
#ifdef SHOPT_VPIX
const char *suffix_list[] = { ".com", ".exe", ".bat", "" };
#endif /* SHOPT_VPIX */

View File

@@ -0,0 +1,136 @@
/* $XConsortium: options.c /main/3 1995/11/01 16:33:24 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <shell.h>
#include "FEATURE/options"
#include "name.h"
#include "shtable.h"
/*
* This is the list of invocation and set options
* This list must be in in ascii sorted order
*/
#define bit32(x) ((x)&0xffff?bit16(x):16+bit16((x)>>16))
#define bit16(x) ((x)&0xff?bit8(x):8+bit8((x)>>8))
#define bit8(x) ((x)&0xf?bit4(x):4+bit4((x)>>4))
#define bit4(x) ((x)&0x3?bit2(x):2+bit2((x)>>2))
#define bit2(x) ((x)&1?0:1)
const Shtable_t shtab_options[] =
{
"allexport", bit32(SH_ALLEXPORT),
"bgnice", bit32(SH_BGNICE),
"emacs", bit32(SH_EMACS),
"errexit", bit32(SH_ERREXIT),
"gmacs", bit32(SH_GMACS),
"ignoreeof", bit32(SH_IGNOREEOF),
"interactive", bit32(SH_INTERACTIVE),
"keyword", bit32(SH_KEYWORD),
"markdirs", bit32(SH_MARKDIRS),
"monitor", bit32(SH_MONITOR),
"noexec", bit32(SH_NOEXEC),
"noclobber", bit32(SH_NOCLOBBER),
"noglob", bit32(SH_NOGLOB),
"nolog", bit32(SH_NOLOG),
"notify", bit32(SH_NOTIFY),
"nounset", bit32(SH_NOUNSET),
"privileged", bit32(SH_PRIVILEGED),
"restricted", bit32(SH_RESTRICTED),
"trackall", bit32(SH_TRACKALL),
"verbose", bit32(SH_VERBOSE),
"vi", bit32(SH_VI),
"viraw", bit32(SH_VIRAW),
"xtrace", bit32(SH_XTRACE),
"", 0
};
const Shtable_t shtab_attributes[] =
{
{"-nnameref", NV_REF},
{"-xexport", NV_EXPORT},
{"-rreadonly", NV_RDONLY},
{"-ttagged", NV_TAGGED},
{"-Eexponential",(NV_INTEGER|NV_DOUBLE|NV_EXPNOTE)},
{"-Ffloat", (NV_INTEGER|NV_DOUBLE)},
{"++short", (NV_INTEGER|NV_SHORT)},
{"++unsigned", (NV_INTEGER|NV_UNSIGN)},
{"-iinteger", NV_INTEGER},
{"-Hfilename", NV_HOST},
{"-llowercase", NV_UTOL},
{"-Zzerofill", NV_ZFILL},
{"-Lleftjust", NV_LJUST},
{"-Rrightjust", NV_RJUST},
{"-uuppercase", NV_LTOU},
{"-Aarray", NV_ARRAY},
{"", 0}
};

View File

@@ -0,0 +1,304 @@
/* $XConsortium: signals.c /main/5 1996/09/06 17:03:12 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include "shtable.h"
#include "fault.h"
#if defined(SIGCLD) && !defined(SIGCHLD)
# define SIGCHLD SIGCLD
#endif
#define VAL(sig,mode) ((sig+1)|(mode)<<SH_SIGBITS)
#define TRAP(n) (((n)|SH_TRAP)-1)
/*
* This is a table that gives numbers and default settings to each signal
* The signal numbers go in the low bits and the attributes go in the high bits
*/
static struct shtable2 _shtab_signals[] =
{
#ifdef SIGABRT
"ABRT", VAL(SIGABRT,SH_SIGDONE), "Abort",
#endif /*SIGABRT */
#ifdef SIGAIO
"AIO", VAL(SIGAIO,SH_SIGIGNORE), "Asynchronous I/O",
#endif /*SIGAIO */
#ifdef SIGALRM
"ALRM", VAL(SIGALRM,SH_SIGFAULT), "Alarm call",
#endif /* SIGALRM */
#ifdef SIGAPOLLO
"APOLLO", VAL(SIGAPOLLO,0), "SIGAPOLLO",
#endif /* SIGAPOLLO */
#ifdef SIGBUS
"BUS", VAL(SIGBUS,SH_SIGDONE), "Bus error",
#endif /* SIGBUS */
#ifdef SIGCHLD
"CHLD", VAL(SIGCHLD,SH_SIGFAULT), "Death of Child",
# ifdef SIGCLD
# if SIGCLD!=SIGCHLD
"CLD", VAL(SIGCLD,SH_SIGFAULT), "Death of Child",
# endif
# endif /* SIGCLD */
#else
# ifdef SIGCLD
"CLD", VAL(SIGCLD,SH_SIGFAULT), "Death of Child",
# endif /* SIGCLD */
#endif /* SIGCHLD */
#ifdef SIGCONT
"CONT", VAL(SIGCONT,SH_SIGIGNORE), "Stopped process continued",
#endif /* SIGCONT */
"DEBUG", VAL(TRAP(SH_DEBUGTRAP),0), "",
#ifdef SIGDIL
"DIL", VAL(SIGDIL,0), "DIL signal",
#endif /* SIGDIL */
#ifdef SIGEMT
"EMT", VAL(SIGEMT,SH_SIGDONE), "EMT trap",
#endif /* SIGEMT */
"ERR", VAL(TRAP(SH_ERRTRAP),0), "",
"EXIT", VAL(0,0), "",
"FPE", VAL(SIGFPE,SH_SIGDONE), "Floating exception",
#ifdef SIGFREEZE
"FREEZE", VAL(SIGFREEZE,SH_SIGIGNORE), "Special signal used by CPR",
#endif /* SIGFREEZE */
"HUP", VAL(SIGHUP,SH_SIGDONE), "Hangup",
"ILL", VAL(SIGILL,SH_SIGDONE), "Illegal instruction",
#ifdef JOBS
"INT", VAL(SIGINT,SH_SIGINTERACTIVE), "Interrupt",
#else
"INT", VAL(SIGINT,SH_SIGINTERACTIVE), "",
#endif /* JOBS */
#ifdef SIGIO
"IO", VAL(SIGIO,SH_SIGIGNORE), "IO signal",
#endif /* SIGIO */
#ifdef SIGIOT
"IOT", VAL(SIGIOT,SH_SIGDONE), "Abort",
#endif /* SIGIOT */
"KEYBD", VAL(TRAP(SH_KEYTRAP),0), "",
#ifdef SIGKILL
"KILL", VAL(SIGKILL,0), "Killed",
#endif /* SIGKILL */
#ifdef SIGLAB
"LAB", VAL(SIGLAB,0), "Security label changed",
#endif /* SIGLAB */
#ifdef SIGLOST
"LOST", VAL(SIGLOST,SH_SIGDONE), "Resources lost",
#endif /* SIGLOST */
#ifdef SIGLWP
"LWP", VAL(SIGLWP,SH_SIGIGNORE), "Special signal used by thread library",
#endif /* SIGLWP */
#ifdef SIGPHONE
"PHONE", VAL(SIGPHONE,0), "Phone interrupt",
#endif /* SIGPHONE */
#ifdef SIGPIPE
#ifdef JOBS
"PIPE", VAL(SIGPIPE,SH_SIGDONE), "Broken Pipe",
#else
"PIPE", VAL(SIGPIPE,SH_SIGDONE), "",
#endif /* JOBS */
#endif /* SIGPIPE */
#ifdef SIGPOLL
"POLL", VAL(SIGPOLL,SH_SIGDONE), "Polling alarm",
#endif /* SIGPOLL */
#ifdef SIGPROF
"PROF", VAL(SIGPROF,SH_SIGDONE), "Profiling time alarm",
#endif /* SIGPROF */
#ifdef SIGPWR
# if SIGPWR>0
"PWR", VAL(SIGPWR,SH_SIGIGNORE), "Power fail",
# endif
#endif /* SIGPWR */
#ifdef SIGQUIT
"QUIT", VAL(SIGQUIT,SH_SIGDONE|SH_SIGINTERACTIVE), "Quit",
#if defined(_SIGRTMAX) || defined(SIGRTMAX)
"RTMAX", 0 /* Filled in at run-time */, "Lowest priority realtime signal",
#endif /* _SIGRTMAX || SIGRTMAX */
#if defined(_SIGRTMIN) || defined(SIGRTMIN)
"RTMIN", 0 /* Filled in at run-time */, "Highest priority realtime signal",
#endif /* _SIGRTMIN || SIGRTMIN */
#endif /* SIGQUIT */
"SEGV", VAL(SIGSEGV,0), "Memory fault",
#ifdef SIGSTOP
"STOP", VAL(SIGSTOP,0), "Stopped (SIGSTOP)",
#endif /* SIGSTOP */
#ifdef SIGSYS
"SYS", VAL(SIGSYS,SH_SIGDONE), "Bad system call",
#endif /* SIGSYS */
"TERM", VAL(SIGTERM,SH_SIGDONE|SH_SIGINTERACTIVE), "Terminated",
#ifdef SIGTINT
# ifdef JOBS
"TINT", VAL(SIGTINT,0), "Interrupt",
# else
"TINT", VAL(SIGTINT,0), "".
# endif /* JOBS */
#endif /* SIGTINT */
#ifdef SIGTRAP
"TRAP", VAL(SIGTRAP,SH_SIGDONE), "Trace/BPT trap",
#endif /* SIGTRAP */
#ifdef SIGTSTP
"TSTP", VAL(SIGTSTP,0), "Stopped",
#endif /* SIGTSTP */
#ifdef SIGTTIN
"TTIN", VAL(SIGTTIN,0), "Stopped (SIGTTIN)",
#endif /* SIGTTIN */
#ifdef SIGTTOU
"TTOU", VAL(SIGTTOU,0), "Stopped(SIGTTOU)",
#endif /* SIGTTOU */
#ifdef SIGURG
"URG", VAL(SIGURG,SH_SIGIGNORE), "Socket interrupt",
#endif /* SIGURG */
#ifdef SIGUSR1
"USR1", VAL(SIGUSR1,SH_SIGDONE), "User signal 1",
#endif /* SIGUSR1 */
#ifdef SIGUSR2
"USR2", VAL(SIGUSR2,SH_SIGDONE), "User signal 2",
#endif /* SIGUSR2 */
#ifdef SIGVTALRM
"VTALRM", VAL(SIGVTALRM,SH_SIGDONE), "Virtual time alarm",
#endif /* SIGVTALRM */
#ifdef SIGWINCH
"WINCH", VAL(SIGWINCH,SH_SIGIGNORE), "Window size change",
#endif /* SIGWINCH */
#ifdef SIGWINDOW
"WINDOW", VAL(SIGWINDOW,SH_SIGIGNORE), "Window size change",
#endif /* SIGWINDOW */
#ifdef SIGWIND
"WIND", VAL(SIGWIND,SH_SIGIGNORE), "Window size change",
#endif /* SIGWIND */
#ifdef SIGMIGRATE
"MIGRATE", VAL(SIGMIGRATE,0), "Migrate process",
#endif /* SIGMIGRATE */
#ifdef SIGDANGER
"DANGER", VAL(SIGDANGER,0), "System crash soon",
#endif /* SIGDANGER */
#ifdef SIGSOUND
"SOUND", VAL(SIGSOUND,0), "Sound completed",
#endif /* SIGSOUND */
#ifdef SIGTHAW
"THAW", VAL(SIGTHAW,SH_SIGIGNORE), "Special signal used by CPR",
#endif /* SIGTHAW */
#ifdef SIGWAITING
"WAITING", VAL(SIGWAITING,SH_SIGIGNORE), "Process lpws are blocked",
#endif /* SIGWAITING */
#ifdef SIGXCPU
"XCPU", VAL(SIGXCPU,SH_SIGDONE|SH_SIGINTERACTIVE), "Exceeded CPU time limit",
#endif /* SIGXCPU */
#ifdef SIGXFSZ
"XFSZ", VAL(SIGXFSZ,SH_SIGDONE|SH_SIGINTERACTIVE), "Exceeded file size limit",
#endif /* SIGXFSZ */
"", 0, 0
};
const struct shtable2 *shtab_signals = _shtab_signals;
/*
* Fill entries whose values can be determined at run-time
* rather than at compile time. Currently only SIGRTMAX/MIN.
*/
void init_shtab_signals __PARAM__((void), ())
{
struct shtable2 *tp = _shtab_signals;
static char init_done = 0;
if (init_done)
return;
#if defined(_SIGRTMAX) || defined(SIGRTMAX)
while (tp->sh_number)
tp++;
/* First one alphabetically is RTMAX. */
# ifdef _SIGRTMAX
tp->sh_number = VAL(_SIGRTMAX, 0);
# else /* SIGRTMAX */
tp->sh_number = VAL(SIGRTMAX, 0);
# endif
tp++;
#endif /* _SIGRTMAX || SIGRTMAX */
#if defined(_SIGRTMIN) || defined(SIGRTMIN)
while (tp->sh_number)
tp++;
/* Second is RTMIN */
# ifdef _SIGRTMIN
tp->sh_number = VAL(_SIGRTMIN, 0);
# else /* SIGRTMIN */
tp->sh_number = VAL(SIGRTMIN, 0);
# endif
#endif /* _SIGRTMIN || SIGRTMIN */
init_done = 1;
}

View File

@@ -0,0 +1,165 @@
/* $XConsortium: strdata.c /main/3 1995/11/01 16:33:51 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "FEATURE/options"
#include "streval.h"
const unsigned char strval_precedence[33] =
/* opcode precedence,assignment */
{
/* DEFAULT */ MAXPREC|NOASSIGN,
/* DONE */ 0|NOASSIGN|RASSOC,
/* NEQ */ 10|NOASSIGN,
/* NOT */ MAXPREC|NOASSIGN,
/* MOD */ 14,
/* ANDAND */ 6|NOASSIGN|SEQPOINT,
/* AND */ 9|NOFLOAT,
/* LPAREN */ MAXPREC|NOASSIGN|SEQPOINT,
/* RPAREN */ 1|NOASSIGN|RASSOC|SEQPOINT,
/* TIMES */ 14,
/* PLUSPLUS */ 15|NOASSIGN|NOFLOAT|SEQPOINT,
/* PLUS */ 13,
/* COMMA */ 1|NOASSIGN|SEQPOINT,
/* MINUSMINUS */ 15|NOASSIGN|NOFLOAT|SEQPOINT,
/* MINUS */ 13,
/* DIV */ 14,
/* LSHIFT */ 12|NOFLOAT,
/* LE */ 11|NOASSIGN,
/* LT */ 11|NOASSIGN,
/* EQ */ 10|NOASSIGN,
/* ASSIGNMENT */ 2|RASSOC,
/* COLON */ 0|NOASSIGN,
/* RSHIFT */ 12|NOFLOAT,
/* GE */ 11|NOASSIGN,
/* GT */ 11|NOASSIGN,
/* QCOLON */ 3|NOASSIGN|SEQPOINT,
/* QUEST */ 3|NOASSIGN|SEQPOINT|RASSOC,
/* XOR */ 8|NOFLOAT,
/* OROR */ 5|NOASSIGN|SEQPOINT,
/* OR */ 7|NOFLOAT,
/* DEFAULT */ MAXPREC|NOASSIGN,
/* DEFAULT */ MAXPREC|NOASSIGN,
/* DEFAULT */ MAXPREC|NOASSIGN
};
/*
* This is for arithmetic expressions
*/
const char strval_states[64] =
{
A_EOF, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
A_REG, 0, 0, A_REG, A_REG, A_REG, A_REG, A_REG,
A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG, A_REG,
0, A_NOT, A_REG, A_REG, A_REG, A_MOD, A_AND, A_REG,
A_LPAR, A_RPAR, A_TIMES,A_PLUS, A_COMMA,A_MINUS,A_DOT, A_DIV,
A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG, A_DIG,
A_DIG, A_DIG, A_COLON,A_REG, A_LT, A_ASSIGN,A_GT, A_QUEST
};
const char e_badnum[] = "%s: bad number";
const char e_moretokens[] = "%s: more tokens expected";
const char e_paren[] = "%s: unbalanced parenthesis";
const char e_badcolon[] = "%s: invalid use of :";
const char e_divzero[] = "%s: divide by zero";
const char e_synbad[] = "%s: arithmetic syntax error";
const char e_notlvalue[] = "%s: assignment requires lvalue";
const char e_recursive[] = "%s: recursion too deep";
const char e_questcolon[] = "%s: ':' expected for '?' operator";
const char e_function[] = "%s: unknown function";
const char e_incompatible[] = "%s: operands have incompatible types";
const char e_overflow[] = "%s: overflow exception";
const char e_domain[] = "%s: domain exception";
const char e_singularity[] = "%s: singularity exception";
const struct mathtab shtab_math[] =
{
"abs", fabs,
'a','c','o','s', acos,
'a','s','i','n', asin,
'a','t','a','n', atan,
"cos", cos,
'c','o','s','h', cosh,
"exp", exp,
"int", floor,
"log", log,
"sin", sin,
's','i','n','h', sinh,
's','q','r','t', sqrt,
"tan", tan,
't','a','n','h', tanh,
"", 0
};

View File

@@ -0,0 +1,107 @@
/* $XConsortium: testops.c /main/3 1995/11/01 16:34:04 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "shtable.h"
#include "test.h"
/*
* This is the list of binary test and [[...]] operators
*/
const Shtable_t shtab_testops[] =
{
"!=", TEST_SNE,
"-a", TEST_AND,
"-ef", TEST_EF,
"-eq", TEST_EQ,
"-ge", TEST_GE,
"-gt", TEST_GT,
"-le", TEST_LE,
"-lt", TEST_LT,
"-ne", TEST_NE,
"-nt", TEST_NT,
"-o", TEST_OR,
"-ot", TEST_OT,
"=", TEST_SEQ,
"==", TEST_SEQ,
"<", TEST_SLT,
">", TEST_SGT,
"]]", TEST_END,
"", 0
};
const char test_opchars[] = "HLSVOGCaeohrwxdcbfugkpsnzt";
const char e_argument[] = "argument expected";
const char e_missing[] = "%s missing";
const char e_badop[] = "%s: unknown operator";
const char e_tstbegin[] = "[[ ! ";
const char e_tstend[] = " ]]\n";

View File

@@ -0,0 +1,154 @@
/* $XConsortium: variables.c /main/3 1995/11/01 16:34:19 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define mount _AST__mount
#include <ast.h>
#include "FEATURE/options"
#include "FEATURE/dynamic"
#include <shell.h>
#include "shtable.h"
#include "name.h"
/*
* This is the list of built-in shell variables and default values
* and default attributes.
*/
const struct shtable2 shtab_variables[] =
{
"PATH", 0, (char*)0,
"PS1", 0, (char*)0,
"PS2", NV_NOFREE, "> ",
"IFS", NV_NOFREE, " \t\n",
"PWD", 0, (char*)0,
"HOME", 0, (char*)0,
"MAIL", 0, (char*)0,
"REPLY", 0, (char*)0,
"SHELL", NV_NOFREE, "/bin/sh",
"EDITOR", 0, (char*)0,
"MAILCHECK", NV_NOFREE|NV_INTEGER, (char*)0,
"RANDOM", NV_NOFREE|NV_INTEGER, (char*)0,
"ENV", 0, (char*)0,
"HISTFILE", 0, (char*)0,
"HISTSIZE", 0, (char*)0,
"HISTEDIT", NV_NOFREE, (char*)0,
"HISTCMD", NV_NOFREE|NV_INTEGER, (char*)0,
"FCEDIT", NV_NOFREE, "/bin/ed",
"CDPATH", 0, (char*)0,
"MAILPATH", 0, (char*)0,
"PS3", NV_NOFREE, "#? ",
"OLDPWD", 0, (char*)0,
"VISUAL", 0, (char*)0,
"COLUMNS", 0, (char*)0,
"LINES", 0, (char*)0,
"PPID", NV_NOFREE|NV_INTEGER, (char*)0,
"_", NV_EXPORT, (char*)0,
"TMOUT", NV_NOFREE|NV_INTEGER, (char*)0,
"SECONDS", NV_NOFREE|NV_INTEGER|NV_DOUBLE, (char*)0,
"LINENO", NV_NOFREE|NV_INTEGER, (char*)0,
"OPTARG", 0, (char*)0,
"OPTIND", NV_NOFREE|NV_INTEGER, (char*)0,
"PS4", 0, (char*)0,
"FPATH", 0, (char*)0,
"LANG", 0, (char*)0,
"LC_ALL", 0, (char*)0,
"LC_COLLATE", 0, (char*)0,
"LC_CTYPE", 0, (char*)0,
"LC_MESSAGES", 0, (char*)0,
"LC_NUMERIC", 0, (char*)0,
"FIGNORE", 0, (char*)0,
".sh", 0, (char*)0,
".sh.edchar", 0, (char*)0,
".sh.edcol", 0, (char*)0,
".sh.edtext", 0, (char*)0,
".sh.edmode", 0, (char*)0,
".sh.name", 0, (char*)0,
".sh.subscript",0, (char*)0,
".sh.value", 0, (char*)0,
".sh.version", NV_NOFREE, (char*)(&e_version[5]),
".sh.dollar", 0, (char*)0,
#ifdef SHOPT_FS_3D
"VPATH", 0, (char*)0,
#endif /* SHOPT_FS_3D */
#ifdef SHOPT_VPIX
"DOSPATH", 0, (char*)0,
"VPIXDIR", 0, (char*)0,
#endif /* SHOPT_VPIX */
#ifdef SHOPT_MULTIBYTE
"CSWIDTH", 0, (char*)0,
#endif /* SHOPT_MULTIBYTE */
#ifdef apollo
"SYSTYPE", 0, (char*)0,
#endif /* apollo */
"", 0, (char*)0
};

View File

@@ -0,0 +1,370 @@
/* $XConsortium: completion.c /main/3 1995/11/01 16:34:34 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <ctype.h>
#include "lexstates.h"
#include "path.h"
#include "io.h"
#include "edit.h"
#include "history.h"
static char macro[] = "_??";
/*
* overwrites <str> to common prefix of <str> and <newstr>
* if <str> is equal to <newstr> returns <str>+strlen(<str>)+1
* otherwise returns <str>+strlen(<str>)
*/
static char *overlay __PARAM__((register char *str,register const char *newstr), (str, newstr)) __OTORP__(register char *str;register const char *newstr;){
while(*str && *str == *newstr++)
str++;
if(*str)
*str = 0;
else if(*newstr==0)
str++;
return(str);
}
/*
* file name generation for edit modes
* non-zero exit for error, <0 ring bell
* don't search back past beginning of the buffer
* mode is '*' for inline expansion,
* mode is '\' for filename completion
* mode is '=' cause files to be listed in select format
*/
ed_expand __PARAM__((char outbuff[],int *cur,int *eol,int mode), (outbuff, cur, eol, mode)) __OTORP__(char outbuff[];int *cur;int *eol;int mode;){
int offset = staktell();
char *staksav = stakptr(0);
struct comnod *comptr = (struct comnod*)stakalloc(sizeof(struct comnod));
struct argnod *ap = (struct argnod*)stakseek(ARGVAL);
register char *out;
char *begin;
int addstar;
int rval = 0;
int strip;
int nomarkdirs = !sh_isoption(SH_MARKDIRS);
#ifdef SHOPT_MULTIBYTE
{
register int c = *cur;
register genchar *cp;
/* adjust cur */
cp = (genchar *)outbuff + *cur;
c = *cp;
*cp = 0;
*cur = ed_external((genchar*)outbuff,(char*)stakptr(0));
*cp = c;
*eol = ed_external((genchar*)outbuff,outbuff);
}
#endif /* SHOPT_MULTIBYTE */
out = outbuff + *cur;
comptr->comtyp = COMSCAN;
comptr->comarg = ap;
ap->argflag = (ARG_MAC|ARG_EXP);
ap->argnxt.ap = 0;
{
register int c;
if(out>outbuff)
{
/* go to beginning of word */
do
{
out--;
c = *(unsigned char*)out;
}
while(out>outbuff && !ismeta(c));
/* copy word into arg */
if(ismeta(c))
out++;
}
else
out = outbuff;
begin = out;
/* addstar set to zero if * should not be added */
addstar = '*';
strip = 1;
/* copy word to arg */
do
{
c = *(unsigned char*)out;
if(isexp(c))
addstar = 0;
if ((c == '/') && (addstar == 0))
strip = 0;
stakputc(c);
out++;
} while (c && !ismeta(c));
out--;
if(mode=='\\')
addstar = '*';
if(*begin=='~' && !strchr(begin,'/'))
addstar = 0;
*stakptr(staktell()-1) = addstar;
stakfreeze(1);
}
if(mode!='*')
sh_onoption(SH_MARKDIRS);
{
register char **com;
char *cp=begin;
int narg,cmd_completion=0;
register int size;
while(cp>outbuff && ((size=cp[-1])==' ' || size=='\t'))
cp--;
if((cp==outbuff || strchr(";&|(",size)) && *begin!='~' && !strchr(ap->argval,'/'))
{
cmd_completion=1;
sh_onstate(SH_COMPLETE);
}
com = sh_argbuild(&narg,comptr);
sh_offstate(SH_COMPLETE);
/* allow a search to be aborted */
if(sh.trapnote&SH_SIGSET)
{
rval = -1;
goto done;
}
/* match? */
if (*com==0 || (narg <= 1 && strcmp(ap->argval,*com)==0))
{
rval = -1;
goto done;
}
if(mode=='=')
{
if (strip && !cmd_completion)
{
register char **ptrcom;
for(ptrcom=com;*ptrcom;ptrcom++)
/* trim directory prefix */
*ptrcom = path_basename(*ptrcom);
}
sfputc(sfstderr,'\n');
sh_menu(sfstderr,narg,com);
sfsync(sfstderr);
goto done;
}
/* see if there is enough room */
size = *eol - (out-begin);
if(mode=='\\')
{
/* just expand until name is unique */
size += strlen(*com);
}
else
{
size += narg;
{
char **savcom = com;
while (*com)
size += strlen(*com++);
com = savcom;
}
}
/* see if room for expansion */
if(outbuff+size >= &outbuff[MAXLINE])
{
com[0] = ap->argval;
com[1] = 0;
}
/* save remainder of the buffer */
strcpy(stakptr(0),out);
if(cmd_completion && mode=='\\')
out = strcopy(begin,path_basename(cp= *com++));
else
out = strcopy(begin,*com++);
if(mode=='\\')
{
char *saveout;
if(addstar==0)
*out++ = '/';
saveout= ++out;
while (*com && *begin)
{
if(cmd_completion)
out = overlay(begin,path_basename(*com++));
else
out = overlay(begin,*com++);
}
mode = (out==saveout);
if(out[-1]==0)
out--;
if(mode && out[-1]!='/')
{
if(cmd_completion)
{
Namval_t *np;
/* add as tracked alias */
if(*cp=='/' && (np=nv_search(begin,sh.track_tree,NV_ADD)))
path_alias(np,cp);
out = strcopy(begin,cp);
}
*out++ = ' ';
}
if(*begin==0)
ed_ringbell();
}
else
while (*com)
{
*out++ = ' ';
out = strcopy(out,*com++);
}
*cur = (out-outbuff);
/* restore rest of buffer */
out = strcopy(out,stakptr(0));
*eol = (out-outbuff);
}
done:
stakset(staksav,offset);
if(nomarkdirs)
sh_offoption(SH_MARKDIRS);
#ifdef SHOPT_MULTIBYTE
{
register int c;
/* first re-adjust cur */
out = outbuff + *cur;
c = *out;
*out = 0;
*cur = ed_internal(outbuff,(genchar*)stakptr(0));
*out = c;
outbuff[*eol+1] = 0;
*eol = ed_internal(outbuff,(genchar*)outbuff);
}
#endif /* SHOPT_MULTIBYTE */
return(rval);
}
/*
* look for edit macro named _i
* if found, puts the macro definition into lookahead buffer and returns 1
*/
ed_macro __PARAM__((register int i), (i)) __OTORP__(register int i;){
register char *out;
Namval_t *np;
genchar buff[LOOKAHEAD+1];
if(i != '@')
macro[1] = i;
/* undocumented feature, macros of the form <ESC>[c evoke alias __c */
if(i=='_')
macro[2] = ed_getchar(1);
else
macro[2] = 0;
if (isalnum(i)&&(np=nv_search(macro,sh.alias_tree,HASH_SCOPE))&&(out=nv_getval(np)))
{
#ifdef SHOPT_MULTIBYTE
/* copy to buff in internal representation */
int c = out[LOOKAHEAD];
out[LOOKAHEAD] = 0;
i = ed_internal(out,buff);
out[LOOKAHEAD] = c;
#else
strncpy((char*)buff,out,LOOKAHEAD);
i = strlen((char*)buff);
#endif /* SHOPT_MULTIBYTE */
while(i-- > 0)
ed_ungetchar(buff[i]);
return(1);
}
return(0);
}
/*
* Enter the fc command on the current history line
*/
ed_fulledit __PARAM__((void), ()){
register char *cp;
if(!sh.hist_ptr)
return(-1);
/* use EDITOR on current command */
if(editb.e_hline == editb.e_hismax)
{
if(editb.e_eol<0)
return(-1);
#ifdef SHOPT_MULTIBYTE
editb.e_inbuf[editb.e_eol+1] = 0;
ed_external(editb.e_inbuf, (char *)editb.e_inbuf);
#endif /* SHOPT_MULTIBYTE */
sfwrite(sh.hist_ptr->histfp,(char*)editb.e_inbuf,editb.e_eol+1);
sh_onstate(SH_HISTORY);
hist_flush(sh.hist_ptr);
}
cp = strcopy((char*)editb.e_inbuf,e_runvi);
cp = strcopy(cp, fmtbase((long)editb.e_hline,10,0));
editb.e_eol = ((unsigned char*)cp - (unsigned char*)editb.e_inbuf)-1;
return(0);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1 @@
cmd newgrp,test,id,wc,cut,logname

View File

@@ -0,0 +1,17 @@
hdr,sys dlfcn,dl,ldr
lib dlopen,shl_load,loadbind
cat{
#ifdef _lib_dlopen
# define SHOPT_FS_3D 1
#endif /* _lib_dlopen */
#ifdef _lib_shl_load
# define SHOPT_FS_3D 1
#endif /* _lib_shl_load */
#ifdef _lib_loadbind
# define SHOPT_FS_3D 1
#endif /* _lib_loadbind */
#ifdef SHOPT_FS_3D
# undef mount
# include <fs3d.h>
#endif /* SHOPT_FS_3D */
}end

View File

@@ -0,0 +1,3 @@
hdr nc
mem exception.name math.h
lib setreuid,setregid,nice,confstr,sigflag,fork

View File

@@ -0,0 +1,21 @@
hdr locale
lib locale,localeconv,wcwidth,mbtowc,mblen
cat{
#ifdef _hdr_locale
# include <locale.h>
# ifdef _lib_localeconv
static struct lconv *lp;
# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point) ? *lp->decimal_point : '.' )
# else
# define GETDECIMAL(x) ('.')
# endif /* _lib_localeconv */
#else
# define GETDECIMAL(x) ('.')
# ifndef _lib_mblen
# undef MULTIBYTE
# endif /* _lib_mblen */
# ifndef _lib_mbtowc
# undef MULTIBYTE
# endif /* _lib_mbtowc */
#endif /* _hdr_locale */
}end

View File

@@ -0,0 +1,63 @@
# $XConsortium: options.sh /main/2 1995/07/19 17:09:54 drk $
: check for shell magic #!
cat > /tmp/file$$ <<!
#! /bin/echo
exit 1
!
chmod 755 /tmp/file$$
if /tmp/file$$ > /dev/null
then echo "#define SHELLMAGIC 1"
fi
rm -f /tmp/file$$
: see whether or not in the ucb universe
if test -f /bin/universe && univ=`/bin/universe` > /dev/null 2>&1
then if test ucb = "$univ"
then echo "#define SHOPT_UCB 1"
fi
fi
if test -d /dev/fd
then echo "#define SHOPT_DEVFD 1"
fi
: Check for VPIX
if test -f /usr/bin/vpix
then echo "#define SHOPT_VPIX 1"
fi
: get the option settings from the options file
. ./OPTIONS
for i in ASSIGN ACCT BRACEPAT DYNAMIC ECHOPRINT ESH FS_3D \
JOBS KIA MULTIBYTE OLDTERMIO OO P_SUID RAWONLY \
SEVENBIT SPAWN SUID_EXEC TIMEOUT VSH
do : This could be done with eval, but eval broken in some shells
j=0
case $i in
ASSIGN) j=$ASSIGN;;
ACCT) j=$ACCT;;
BRACEPAT) j=$BRACEPAT;;
DYNAMIC) j=$DYNAMIC;;
ECHOPRINT) j=$ECHOPRINT;;
ESH) j=$ESH;;
FS_3D) j=$FS_3D;;
JOBS) j=$JOBS;;
KIA) j=$KIA;;
MULTIBYTE) j=$MULTIBYTE;;
OLDTERMIO) echo "#include <sys/termios.h>" > /tmp/dummy$$.c
echo "#include <sys/termio.h>" >>/tmp/dummy$$.c
if ${CC-cc} -E /tmp/dummy$$.c > /dev/null 2>&1
then j=$OLDTERMIO
fi
rm -f dummy$$.c;;
OO) j=$OO;;
P_SUID) j=$P_SUID;;
RAWONLY) j=$RAWONLY;;
SEVENBIT) j=$SEVENBIT;;
SPAWN) j=$SPAWN;;
SUID_EXEC) j=$SUID_EXEC;;
TIMEOUT) j=$TIMEOUT;;
VSH) j=$VSH;;
esac
case $j in
0|"") ;;
*) echo "#define SHOPT_$i $j" ;;
esac
done

View File

@@ -0,0 +1,34 @@
hdr,sys poll,socket,netinet/in
lib select,poll,socket
typ fd_set sys/socket.h
cat{
#pragma prototyped
#ifdef _lib_poll
# define poll _SYS_poll
#else
# undef _hdr_poll
# undef _sys_poll
#endif /* _lib_poll */
#ifdef _hdr_poll
# include <poll.h>
#else
# ifdef _sys_poll
# include <sys/poll.h>
# endif /* _sys_poll */
#endif /* _hdr_poll */
#ifdef _lib_poll
# undef poll
extern int poll(struct pollfd*,unsigned long,int);
#endif /* _lib_poll */
#ifdef _lib_select
# ifndef FD_ZERO
# define FD_ZERO(x) (*(x)=0)
# endif /* FD_ZERO */
# ifndef FD_SET
# define FD_SET(n,x) (*(x)|=(1L<<(n)))
# endif /* FD_SET */
# ifndef _typ_fd_set
typedef long fd_set;
# endif /*_typ_fd_set */
#endif /* _lib_select */
}end

View File

@@ -0,0 +1,2 @@
hdr,sys resource,vlimit
lib getrlimit,ulimit,vlimit

View File

@@ -0,0 +1,15 @@
lib sigsetjmp,_setjmp
typ sigjmp_buf setjmp.h
cat{
#undef sigsetjmp
#undef siglongjmp
#undef sigjmp_buf
#define sigjmp_buf jmp_buf
#ifdef _lib__setjmp
# define sigsetjmp(a,b) _setjmp(a)
# define siglongjmp(a,b) _longjmp(a,b)
#else
# define sigsetjmp(a,b) setjmp(a)
# define siglongjmp(a,b) longjmp(a,b)
#endif /* _lib__setjmp */
}end

View File

@@ -0,0 +1,28 @@
lib sigblock,sigrelse,sigsetmask,sigprocmask,sigvec
typ sigset_t ast.h,signal.h
mem sigvec.sv_mask signal.h
cat{
#ifndef _mem_sigvec_sv_mask
# undef _lib_sigvec
#endif
#ifdef _lib_sigsetmask
# define sigrelease(s) sigsetmask(0)
# define sig_begin() sigsetmask(0)
#else
# ifdef _lib_sigrelse
# define sigrelease sigrelse
# define sig_begin()
# else
# ifdef _lib_sigprocmask
# define sigrelease(s) do { sigset_t ss;\
sigemptyset(&ss);\
sigprocmask(SIG_SETMASK,&ss,0); \
}while(0)
# define sig_begin() sigrelease(0)
# else
# define sig_begin() (0)
# define sigrelease(s) (0)
# endif /* _lib_sigrelse */
# endif /* _lib_sigprocmask */
#endif /* _lib_sigsetmask */
}end

View File

@@ -0,0 +1,8 @@
hdr utime
lib gettimeofday,setitimer
mem timeval.tv_usec sys/time.h
cat{
#undef _def_time
#include <times.h>
#define _def_time 1
}end

View File

@@ -0,0 +1,3 @@
hdr termios,termio,sgtty
sys termios,termio,ioctl,bsdtty,nttyio,filio
lib tcgetattr,tcgetpgrp

View File

@@ -0,0 +1 @@
cmd newgrp,test,id,wc,cut,logname,universe

View File

@@ -0,0 +1,17 @@
hdr,sys dlfcn,dl,ldr
lib dlopen,shl_load,loadbind
cat{
#ifdef _lib_dlopen
# define SHOPT_FS_3D 1
#endif /* _lib_dlopen */
#ifdef _lib_shl_load
# define SHOPT_FS_3D 1
#endif /* _lib_shl_load */
#ifdef _lib_loadbind
# define SHOPT_FS_3D 1
#endif /* _lib_loadbind */
#ifdef SHOPT_FS_3D
# undef mount
# include <fs3d.h>
#endif /* SHOPT_FS_3D */
}end

View File

@@ -0,0 +1,3 @@
hdr nc
mem exception.name math.h
lib setreuid,setregid,nice,confstr,sigflag,fork,spawnveg

View File

@@ -0,0 +1,21 @@
hdr locale,wchar
lib locale,localeconv,wcwidth,mbtowc,mblen,wctype,iswctype,iswblank
cat{
#ifdef _hdr_locale
# include <locale.h>
# ifdef _lib_localeconv
static struct lconv *lp;
# define GETDECIMAL(x) (((lp=localeconv()) && lp->decimal_point && *lp->decimal_point) ? *lp->decimal_point : '.' )
# else
# define GETDECIMAL(x) ('.')
# endif /* _lib_localeconv */
#else
# define GETDECIMAL(x) ('.')
# ifndef _lib_mblen
# undef MULTIBYTE
# endif /* _lib_mblen */
# ifndef _lib_mbtowc
# undef MULTIBYTE
# endif /* _lib_mbtowc */
#endif /* _hdr_locale */
}end

View File

@@ -0,0 +1,77 @@
: $XConsortium: options.sh /main/2 1996/05/10 16:42:10 drk $
: check for shell magic #!
: include OPTIONS
eval $1
shift
OPTIONS=$1
cat > /tmp/file$$ <<!
#! /bin/echo
exit 1
!
chmod 755 /tmp/file$$
if /tmp/file$$ > /dev/null
then echo "#define SHELLMAGIC 1"
fi
rm -f /tmp/file$$
: see whether or not in the ucb universe
if test -f /bin/universe && univ=`/bin/universe` > /dev/null 2>&1
then if test ucb = "$univ"
then echo "#define SHOPT_UCB 1"
fi
fi
if test -d /dev/fd
then echo "#define SHOPT_DEVFD 1"
fi
: Check for VPIX
if test -f /usr/bin/vpix
then echo "#define SHOPT_VPIX 1"
fi
: get the option settings from the options file
if [ -z "$OPTIONS" ] ; then
OPTIONS="OPTIONS"
fi
. $OPTIONS
for i in ACCT ACCTFILE BRACEPAT CRNL DYNAMIC ECHOPRINT ESH FS_3D \
JOBS KIA MULTIBYTE OLDTERMIO OO P_SUID RAWONLY \
SEVENBIT SPAWN SUID_EXEC TIMEOUT VSH
do : This could be done with eval, but eval broken in some shells
j=0
case $i in
ACCT) j=$ACCT;;
ACCTFILE) j=$ACCTFILE;;
BRACEPAT) j=$BRACEPAT;;
CRNL) j=$CRNL;;
DYNAMIC) j=$DYNAMIC;;
ECHOPRINT) j=$ECHOPRINT;;
ESH) j=$ESH;;
FS_3D) j=$FS_3D;;
JOBS) j=$JOBS;;
KIA) j=$KIA;;
MULTIBYTE) j=$MULTIBYTE;;
OLDTERMIO) echo "#include <sys/termios.h>" > /tmp/dummy$$.c
echo "#include <sys/termio.h>" >>/tmp/dummy$$.c
if $cc -E /tmp/dummy$$.c > /dev/null 2>&1
then j=$OLDTERMIO
fi
rm -f dummy$$.c;;
OO) j=$OO;;
P_SUID) j=$P_SUID;;
RAWONLY) j=$RAWONLY;;
SEVENBIT) j=$SEVENBIT;;
SPAWN) j=$SPAWN;;
SUID_EXEC) j=$SUID_EXEC;;
TIMEOUT) j=$TIMEOUT;;
VSH) j=$VSH;;
esac
case $j in
0|"") ;;
*) echo "#define SHOPT_$i $j" ;;
esac
done
cat <<\!
#if (MB_LEN_MAX-1)<=0 || !defined(_lib_mbtowc)
# undef SHOPT_MULTIBYTE
#endif
!

View File

@@ -0,0 +1,34 @@
hdr,sys poll,socket,netinet/in
lib select,poll,socket
typ fd_set sys/socket.h
cat{
#pragma prototyped
#ifdef _lib_poll
# define poll _SYS_poll
#else
# undef _hdr_poll
# undef _sys_poll
#endif /* _lib_poll */
#ifdef _hdr_poll
# include <poll.h>
#else
# ifdef _sys_poll
# include <sys/poll.h>
# endif /* _sys_poll */
#endif /* _hdr_poll */
#ifdef _lib_poll
# undef poll
extern int poll(struct pollfd*,unsigned long,int);
#endif /* _lib_poll */
#ifdef _lib_select
# ifndef FD_ZERO
# define FD_ZERO(x) (*(x)=0)
# endif /* FD_ZERO */
# ifndef FD_SET
# define FD_SET(n,x) (*(x)|=(1L<<(n)))
# endif /* FD_SET */
# ifndef _typ_fd_set
typedef long fd_set;
# endif /*_typ_fd_set */
#endif /* _lib_select */
}end

View File

@@ -0,0 +1,2 @@
hdr,sys resource,vlimit
lib getrlimit,ulimit,vlimit

View File

@@ -0,0 +1,18 @@
lib sigsetjmp,_setjmp,_longjmp
typ sigjmp_buf setjmp.h
cat{
#undef sigsetjmp
#undef siglongjmp
#undef sigjmp_buf
#define sigjmp_buf jmp_buf
#ifdef _lib__setjmp
# define sigsetjmp(a,b) _setjmp(a)
#else
# define sigsetjmp(a,b) setjmp(a)
#endif /* _lib__setjmp */
#ifdef _lib__longjmp
# define siglongjmp(a,b) _longjmp(a,b)
#else
# define siglongjmp(a,b) longjmp(a,b)
#endif /* _lib__longjmp */
}end

View File

@@ -0,0 +1,28 @@
lib sigblock,sigrelse,sigsetmask,sigprocmask,sigvec
typ sigset_t ast.h,signal.h
mem sigvec.sv_mask signal.h
cat{
#ifndef _mem_sigvec_sv_mask
# undef _lib_sigvec
#endif
#ifdef _lib_sigsetmask
# define sigrelease(s) sigsetmask(0)
# define sig_begin() sigsetmask(0)
#else
# ifdef _lib_sigrelse
# define sigrelease sigrelse
# define sig_begin()
# else
# ifdef _lib_sigprocmask
# define sigrelease(s) do { sigset_t ss;\
sigemptyset(&ss);\
sigprocmask(SIG_SETMASK,&ss,0); \
}while(0)
# define sig_begin() sigrelease(0)
# else
# define sig_begin() (0)
# define sigrelease(s) (0)
# endif /* _lib_sigrelse */
# endif /* _lib_sigprocmask */
#endif /* _lib_sigsetmask */
}end

View File

@@ -0,0 +1,8 @@
hdr utime
lib gettimeofday,setitimer
mem timeval.tv_usec sys/time.h
cat{
#undef _def_time
#include <times.h>
#define _def_time 1
}end

View File

@@ -0,0 +1,3 @@
hdr termios,termio,sgtty
sys termios,termio,ioctl,bsdtty,nttyio,filio
lib tcgetattr,tcgetpgrp

View File

@@ -0,0 +1,50 @@
./" $XConsortium: grep.mm /main/2 1995/07/18 10:14:53 drk $
# SHELL VERSION OF GREP
#
vflag= xflag= cflag= lflag= nflag=
set -f
integer errors=0
while getopts "ce:f:[file]ilnxv [file]..." opt # look for grep options
do case $opt in
v) vflag=1;;
x) xflag=1;;
c) cflag=1;;
l) lflag=1;;
n) nflag=1;;
e) expr=$OPTARG;;
f) expr=$(< $OPTARG);;
esac
done
(( $? == 2 )) && exit 2
shift $((OPTIND-1)) # next argument
if [[ ! $expr ]]
then expr=$1;shift
fi
[[ $xflag ]] || expr="*${expr}*"
noprint=$vflag$cflag$lflag # don't print if these flags are set
integer n=0 c=0 tc=0 nargs=$# # initialize counters
for i # go thru the files
do if ((nargs<=1))
then fname=''
else fname=$i:
fi
[[ $i ]] && exec 0< $i # open file if necessary
while read -r line # read in a line
do (( n++ ))
case $line in
$expr) # line matches pattern
[[ $noprint ]] || print -r -- "$fname${nflag:+$n:}$line"
(( c++ ));;
*) # not a match
if [[ $vflag ]]
then print -r -- "$fname${nflag:+$n:}$line"
fi;;
esac
done
if [[ $lflag ]] && ((c))
then print $i
fi
(( tc+=c,n=0,c=0 ))
done
[[ $cflag ]] && print $tc # print count if cflag is set
exit $((tc==0)) # set the exit value

View File

@@ -0,0 +1,194 @@
/* $XConsortium: argnod.h /main/3 1995/11/01 16:38:43 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef ARG_RAW
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* struct to hold a word argument
* Written by David Korn
*
*/
#include <stak.h>
struct ionod
{
unsigned iofile;
char *ioname;
struct ionod *ionxt;
struct ionod *iolst;
char *iodelim;
off_t iooffset;
long iosize;
};
struct comnod
{
int comtyp;
struct ionod *comio;
struct argnod *comarg;
struct argnod *comset;
__V_ *comnamp;
int comline;
};
#define COMBITS 4
#define COMMSK ((1<<COMBITS)-1)
#define COMSCAN (01<<COMBITS)
struct slnod /* struct for link list of stacks */
{
struct slnod *slnext;
struct slnod *slchild;
Stak_t *slptr;
};
/*
* This struct is use to hold $* lists and arrays
*/
struct dolnod
{
short dolrefcnt; /* reference count */
short dolmax; /* size of dolval array */
short dolnum; /* number of elements */
short dolbot; /* current first element */
struct dolnod *dolnxt; /* used when list are chained */
char *dolval[1]; /* array of value pointers */
};
/*
* This struct is used to hold word arguments of variable size during
* parsing and during expansion. The flags indicate what processing
* is required on the argument.
*/
struct argnod
{
union
{
struct argnod *ap;
char *cp;
} argnxt;
union
{
struct argnod *ap;
int len;
} argchn;
unsigned char argflag;
char argval[4];
};
/* The following should evaluate to the offset of argval in argnod */
extern __MANGLE__ int errno; /* could be any l-value */
#define ARGVAL ((unsigned)(((struct argnod*)(&errno))->argval-(char*)(&errno)))
#define sh_argstr(ap) ((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
#ifdef SHOPT_VPIX
# define ARG_SPARE 2
#else
# define ARG_SPARE 1
#endif /* SHOPT_VPIX */
/* legal argument flags */
#define ARG_RAW 0x1 /* string needs no processing */
#define ARG_MAKE 0x2 /* bit set during argument expansion */
#define ARG_MAC 0x4 /* string needs macro expansion */
#define ARG_EXP 0x8 /* string needs file expansion */
#define ARG_ASSIGN 0x10 /* argument is an assignment */
#define ARG_QUOTED 0x20 /* word contained quote characters */
#define ARG_MESSAGE 0x40 /* contains international string */
#define ARG_APPEND 0x80 /* for += assignment */
extern __MANGLE__ char **sh_argbuild __PROTO__((int*,const struct comnod*));
extern __MANGLE__ struct dolnod *sh_argcreate __PROTO__((char*[]));
extern __MANGLE__ char *sh_argdolminus __PROTO__((void));
extern __MANGLE__ struct dolnod *sh_argfree __PROTO__((struct dolnod*,int));
extern __MANGLE__ struct dolnod *sh_argnew __PROTO__((char*[],struct dolnod**));
extern __MANGLE__ int sh_argopts __PROTO__((int,char*[]));
extern __MANGLE__ void sh_argreset __PROTO__((struct dolnod*,struct dolnod*));
extern __MANGLE__ void sh_argset __PROTO__((char*[]));
extern __MANGLE__ struct dolnod *sh_arguse __PROTO__((void));
extern __MANGLE__ const char e_heading[];
extern __MANGLE__ const char e_off[];
extern __MANGLE__ const char e_on[];
extern __MANGLE__ const char e_sptbnl[];
extern __MANGLE__ const char e_subst[];
extern __MANGLE__ const char e_option[];
extern __MANGLE__ const char e_argexp[];
extern __MANGLE__ const char e_exec[];
extern __MANGLE__ const char e_devfdNN[];
#endif /* ARG_RAW */

View File

@@ -0,0 +1,258 @@
/* $XConsortium: builtins.h /main/3 1995/11/01 16:39:00 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SYSDECLARE
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <option.h>
#include "FEATURE/options"
#include "FEATURE/dynamic"
#include "shtable.h"
#define SYSLOGIN (sh.bltin_cmds)
#define SYSEXEC (sh.bltin_cmds+1)
#define SYSSET (sh.bltin_cmds+2)
#define SYSTRUE (sh.bltin_cmds+4)
#define SYSCOMMAND (sh.bltin_cmds+5)
#define SYSCD (sh.bltin_cmds+6)
#define SYSBREAK (sh.bltin_cmds+7)
#define SYSCONT (sh.bltin_cmds+8)
#define SYSTYPESET (sh.bltin_cmds+9)
#define SYSTEST (sh.bltin_cmds+10)
#define SYSBRACKET (sh.bltin_cmds+11)
/* entry point for shell special builtins */
extern __MANGLE__ int b_alias __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_brk_cont __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_dot_cmd __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_exec __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_eval __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_ret_exit __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_login __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_true __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_false __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_read_export __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_set __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_shift __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_trap __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_typeset __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_unset __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_unalias __PROTO__((int, char*[],__V_*));
/* The following are for job control */
#if defined(SIGCLD) || defined(SIGCHLD)
extern __MANGLE__ int b_jobs __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_kill __PROTO__((int, char*[],__V_*));
# ifdef SIGTSTP
extern __MANGLE__ int b_bg_fg __PROTO__((int, char*[],__V_*));
# endif /* SIGTSTP */
#endif
/* The following utilities are built-in because of side-effects */
extern __MANGLE__ int b_builtin __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_cd __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_command __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_getopts __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_hist __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_let __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_read __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_ulimit __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_umask __PROTO__((int, char*[],__V_*));
#ifdef _cmd_universe
extern __MANGLE__ int b_universe __PROTO__((int, char*[],__V_*));
#endif /* _cmd_universe */
#ifdef SHOPT_FS_3D
extern __MANGLE__ int b_vpath_map __PROTO__((int, char*[],__V_*));
#endif /* SHOPT_FS_3D */
extern __MANGLE__ int b_wait __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_whence __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_alarm __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_print __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_printf __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_pwd __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_sleep __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_test __PROTO__((int, char*[],__V_*));
#ifndef SHOPT_ECHOPRINT
extern __MANGLE__ int b_echo __PROTO__((int, char*[],__V_*));
#endif /* SHOPT_ECHOPRINT */
/* The following utilities need not be built-ins, but improve performance */
extern __MANGLE__ int b_basename __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_cat __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_chmod __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_cmp __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_cut __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_dirname __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_getconf __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_head __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_id __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_logname __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_mkdir __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_tail __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_tty __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_uname __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_wc __PROTO__((int, char*[],__V_*));
/* The following are extensions for apollo computers */
#ifdef apollo
extern __MANGLE__ int b_rootnode __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_inlib __PROTO__((int, char*[],__V_*));
extern __MANGLE__ int b_ver __PROTO__((int, char*[],__V_*));
#endif /* apollo */
extern __MANGLE__ const char e_alrm1[];
extern __MANGLE__ const char e_alrm2[];
extern __MANGLE__ const char e_badfun[];
extern __MANGLE__ const char e_baddisc[];
extern __MANGLE__ const char e_nofork[];
extern __MANGLE__ const char e_nosignal[];
extern __MANGLE__ const char e_nolabels[];
extern __MANGLE__ const char e_notimp[];
extern __MANGLE__ const char e_nosupport[];
extern __MANGLE__ const char e_badbase[];
extern __MANGLE__ const char e_overlimit[];
extern __MANGLE__ const char e_needspath[];
extern __MANGLE__ const char e_eneedsarg[];
extern __MANGLE__ const char e_toodeep[];
extern __MANGLE__ const char e_badconf[];
extern __MANGLE__ const char e_badname[];
extern __MANGLE__ const char e_badwrite[];
extern __MANGLE__ const char e_badsyntax[];
#ifdef _cmd_universe
extern __MANGLE__ const char e_nouniverse[];
#endif /* _cmd_universe */
extern __MANGLE__ const char e_histopen[];
extern __MANGLE__ const char e_condition[];
extern __MANGLE__ const char e_badrange[];
extern __MANGLE__ const char e_numeric[];
extern __MANGLE__ const char e_trap[];
extern __MANGLE__ const char e_direct[];
extern __MANGLE__ const char e_defedit[];
extern __MANGLE__ const char e_cneedsarg[];
#ifdef SHOPT_FS_3D
extern __MANGLE__ const char e_cantset[];
extern __MANGLE__ const char e_cantget[];
extern __MANGLE__ const char e_mapping[];
extern __MANGLE__ const char e_versions[];
#endif /* SHOPT_FS_3D */
#ifdef apollo
extern __MANGLE__ const char e_rootnode[];
extern __MANGLE__ const char e_nover[];
extern __MANGLE__ const char e_badver[];
extern __MANGLE__ const char e_badinlib[];
#endif /* apollo */
/* for option parsing */
extern __MANGLE__ const char sh_optalarm[];
extern __MANGLE__ const char sh_optalias[];
extern __MANGLE__ const char sh_optbuiltin[];
extern __MANGLE__ const char sh_optcd[];
extern __MANGLE__ const char sh_optcflow[];
extern __MANGLE__ const char sh_optcommand[];
extern __MANGLE__ const char sh_optdot[];
#ifndef ECHOPRINT
extern __MANGLE__ const char sh_optecho[];
#endif /* !ECHOPRINT */
extern __MANGLE__ const char sh_opteval[];
extern __MANGLE__ const char sh_optexec[];
extern __MANGLE__ const char sh_optexport[];
extern __MANGLE__ const char sh_optgetopts[];
extern __MANGLE__ const char sh_optgetconf[];
extern __MANGLE__ const char sh_optjoblist[];
extern __MANGLE__ const char sh_opthist[];
extern __MANGLE__ const char sh_optjobs[];
extern __MANGLE__ const char sh_optkill[];
extern __MANGLE__ const char sh_optksh[];
extern __MANGLE__ const char sh_optlet[];
extern __MANGLE__ const char sh_optprint[];
extern __MANGLE__ const char sh_optprintf[];
extern __MANGLE__ const char sh_optpwd[];
extern __MANGLE__ const char sh_optread[];
extern __MANGLE__ const char sh_optset[];
extern __MANGLE__ const char sh_optsleep[];
extern __MANGLE__ const char sh_opttrap[];
extern __MANGLE__ const char sh_opttypeset[];
extern __MANGLE__ const char sh_optulimit[];
extern __MANGLE__ const char sh_optumask[];
extern __MANGLE__ const char sh_optunalias[];
#ifdef _cmd_universe
extern __MANGLE__ const char sh_optuniverse[];
#endif /* _cmd_universe */
extern __MANGLE__ const char sh_optunset[];
#ifdef SHOPT_FS_3D
extern __MANGLE__ const char sh_optvpath[];
extern __MANGLE__ const char sh_optvmap[];
#endif /* SHOPT_FS_3D */
extern __MANGLE__ const char sh_optwhence[];
#endif /* SYSDECLARE */

View File

@@ -0,0 +1,231 @@
/* $XConsortium: defs.h /main/3 1995/11/01 16:39:16 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define mount _AST__mount
#include <ast.h>
#include <sfio.h>
#include <error.h>
#include "FEATURE/options"
#include <history.h>
#include "fault.h"
#include "argnod.h"
struct sh_scoped
{
struct slnod *staklist; /* link list of function stacks */
int states;
int breakcnt;
int execbrk;
int loopcnt;
int firstline;
int dolc;
char **dolv;
long optindex;
long optnum;
short optchar;
short opterror;
char *cmdname;
int ioset;
short trapmax;
char *trap[SH_DEBUGTRAP+1];
char **trapcom;
char **otrapcom;
__V_ *timetrap;
__V_ *par_tree; /* for calling function */
struct sh_scoped *prevst; /* pointer to previous state */
};
struct limits
{
int open_max; /* maximum number of file descriptors */
int clk_tck; /* number of ticks per second */
int child_max; /* maxumum number of children */
int ngroups_max; /* maximum number of process groups */
unsigned char posix_version; /* posix version number */
unsigned char posix_jobcontrol;/* non-zero for job control systems */
unsigned char fs3d; /* non-zero for 3-d file system */
};
#define _SH_PRIVATE \
struct sh_scoped st; /* scoped information */ \
struct limits lim; /* run time limits */ \
Hashtab_t *track_tree; /* for tracked aliases*/ \
Hashtab_t *bltin_tree; /* for builtin commands */ \
Hashtab_t *var_base; /* global level variables */ \
History_t *hist_ptr; /* history file pointer */ \
Sfio_t *outpool; /* ouput stream pool */ \
long timeout; /* read timeout */ \
long tmout; /* value for TMOUT */ \
int curenv; /* current subshell number */ \
int jobenv; /* subshell number for jobs */ \
int nextprompt; /* next prompt is PS<nextprompt> */ \
Namval_t *bltin_cmds; /* pointer to built-in commands */ \
Namval_t *posix_fun; /* points to last name() function */ \
int infd; /* input file descriptor */ \
char *outbuff; /* pointer to output buffer */ \
char *errbuff; /* pointer to stderr buffer */ \
char *prompt; /* pointer to prompt string */ \
char *shname; /* shell name */ \
char *comdiv; /* points to sh -c argument */ \
char *prefix; /* prefix for compound assignment */ \
sigjmp_buf *jmplist; /* longjmp return stack */ \
char **sigmsg; /* points to signal messages */ \
int oldexit; \
uid_t userid,euserid; /* real and effective user id */ \
gid_t groupid,egroupid;/* real and effective group id */ \
pid_t pid; /* process id of shell */ \
pid_t bckpid; /* background process id */ \
pid_t cpid; \
long ppid; /* parent process id of shell */ \
int topfd; \
int sigmax; /* maximum number of signals */ \
unsigned char *sigflag; /* pointer to signal states */ \
char intrap; \
char login_sh; \
char lastbase; \
char universe; \
char forked; \
char binscript; \
char used_pos; /* used postional parameter */\
unsigned char lastsig; /* last signal received */ \
char *readscript; /* set before reading a script */ \
int *inpipe; /* input pipe pointer */ \
int *outpipe; /* output pipe pointer */ \
int cpipe[2]; \
int coutpipe; \
struct argnod *envlist; \
struct dolnod *arglist; \
int fn_depth; \
int dot_depth; \
long nforks; \
char ifstable[256];
#include <shell.h>
/* error exits from various parts of shell */
#define NIL(type) ((type)0)
#define new_of(type,x) ((type*)malloc((unsigned)sizeof(type)+(x)))
#define exitset() (sh.savexit=sh.exitval)
/* states */
/* low numbered states are same as options */
#define SH_NOFORK 0x1 /* set when fork not necessary, not a state */
#define SH_COMPLETE 0x1 /* set for command completion */
#define SH_TTYWAIT 0x40 /* waiting for keyboard input */
#define SH_FORKED 0x80 /* set when process has been forked */
#define SH_PROFILE 0x100 /* set when processing profiles */
#define SH_NOALIAS 0x200 /* do not expand non-exported aliases */
#define SH_NOTRACK 0x400 /* set to disable sftrack() function */
#define SH_STOPOK 0x800 /* set for stopable builtins */
#define SH_GRACE 0x1000 /* set for timeout grace period */
#define SH_TIMING 0x2000 /* set while timing pipelines */
#define SH_DEFPATH 0x4000 /* set when using default path */
#define SH_INIT 0x8000 /* set when initializing the shell */
extern __MANGLE__ Namval_t *sh_assignok __PROTO__((Namval_t*,int));
extern __MANGLE__ int sh_echolist __PROTO__((Sfio_t*, int, char**));
extern __MANGLE__ struct argnod *sh_endword __PROTO__((int));
extern __MANGLE__ char **sh_envgen __PROTO__((void));
extern __MANGLE__ void sh_envnolocal __PROTO__((Namval_t*));
extern __MANGLE__ char *sh_etos __PROTO__((double,int));
extern __MANGLE__ char *sh_ftos __PROTO__((double,int));
extern __MANGLE__ double sh_arith __PROTO__((const char*));
extern __MANGLE__ pid_t sh_fork __PROTO__((int,int*));
extern __MANGLE__ char *sh_mactrim __PROTO__((char*,int));
extern __MANGLE__ int sh_macexpand __PROTO__((struct argnod*,struct argnod**));
extern __MANGLE__ void sh_machere __PROTO__((Sfio_t*, Sfio_t*, char*));
extern __MANGLE__ char *sh_mactry __PROTO__((char*));
extern __MANGLE__ int sh_readline __PROTO__((char**,int,int,long));
extern __MANGLE__ void sh_reinit __PROTO__((char*[]));
extern __MANGLE__ Sfio_t *sh_sfeval __PROTO__((char*[]));
extern __MANGLE__ void sh_subtmpfile __PROTO__((void));
extern __MANGLE__ Sfio_t *sh_subshell __PROTO__((union anynode*, int, int));
extern __MANGLE__ char *sh_substitute __PROTO__((const char*,const char*,char*));
extern __MANGLE__ int sh_tdump __PROTO__((Sfio_t*, const union anynode*));
extern __MANGLE__ int sh_trace __PROTO__((char*[],int));
extern __MANGLE__ union anynode *sh_trestore __PROTO__((Sfio_t*));
extern __MANGLE__ void sh_trim __PROTO__((char*));
extern __MANGLE__ void sh_userinit __PROTO__((void));
extern __MANGLE__ int sh_whence __PROTO__((char**,int));
#define sh_isstate(x) (sh.st.states&((int)(x)))
#define sh_onstate(x) (sh.st.states |= ((int)(x)))
#define sh_setstate(x) (sh.st.states = ((int)(x)))
#define sh_offstate(x) (sh.st.states &= ~((int)(x)))
extern __MANGLE__ time_t sh_mailchk;

View File

@@ -0,0 +1,241 @@
/* $XConsortium: edit.h /main/3 1995/11/01 16:39:33 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SEARCHSIZE
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* edit.h - common data structure for vi and emacs edit options
*
* David Korn
* AT&T Bell Laboratories
* Room 2B-102
* Murray Hill, N. J. 07974
* Tel. x7975
*
*/
#define SEARCHSIZE 80
#include "FEATURE/options"
#if !defined(SHOPT_VSH) && !defined (SHOPT_ESH)
# define ed_winsize() (SEARCHSIZE)
#else
#ifndef KSHELL
# include <setjmp.h>
# include <sig.h>
# include <ctype.h>
#endif /* KSHELL */
#include "FEATURE/setjmp"
#ifdef SHOPT_SEVENBIT
# define STRIP 0177
#else
# define STRIP 0377
#endif /* SHOPT_SEVENBIT */
#define LOOKAHEAD 80
#ifdef SHOPT_MULTIBYTE
# ifndef ESS_MAXCHAR
# include "national.h"
# endif /* ESS_MAXCHAR */
# if ESS_MAXCHAR<=2
typedef unsigned short genchar;
# else
typedef long genchar;
# endif
# define CHARSIZE 2
#else
typedef char genchar;
# define CHARSIZE 1
#endif /* SHOPT_MULTIBYTE */
#define TABSIZE 8
#define PRSIZE 80
#define MAXLINE 502 /* longest edit line permitted */
struct edit
{
int e_kill;
int e_erase;
int e_werase;
int e_eof;
int e_lnext;
int e_fchar;
char e_plen; /* length of prompt string */
char e_crlf; /* zero if cannot return to beginning of line */
sigjmp_buf e_env;
int e_llimit; /* line length limit */
int e_hline; /* current history line number */
int e_hloff; /* line number offset for command */
int e_hismin; /* minimum history line number */
int e_hismax; /* maximum history line number */
int e_raw; /* set when in raw mode or alt mode */
int e_cur; /* current line position */
int e_eol; /* end-of-line position */
int e_pcur; /* current physical line position */
int e_peol; /* end of physical line position */
int e_mode; /* edit mode */
int e_index; /* index in look-ahead buffer */
int e_repeat;
int e_saved;
int e_fcol; /* first column */
int e_ucol; /* column for undo */
int e_wsize; /* width of display window */
char *e_outbase; /* pointer to start of output buffer */
char *e_outptr; /* pointer to position in output buffer */
char *e_outlast; /* pointer to end of output buffer */
genchar *e_inbuf; /* pointer to input buffer */
char *e_prompt; /* pointer to buffer containing the prompt */
genchar *e_ubuf; /* pointer to the undo buffer */
genchar *e_killbuf; /* pointer to delete buffer */
char e_search[SEARCHSIZE]; /* search string */
genchar *e_Ubuf; /* temporary workspace buffer */
genchar *e_physbuf; /* temporary workspace buffer */
int e_lbuf[LOOKAHEAD];/* pointer to look-ahead buffer */
int e_fd; /* file descriptor */
int e_ttyspeed; /* line speed, also indicates tty parms are valid */
int *e_globals; /* global variables */
genchar *e_window; /* display window image */
char e_inmacro; /* processing macro expansion */
#ifndef KSHELL
char e_prbuff[PRSIZE]; /* prompt buffer */
#endif /* KSHELL */
};
#undef MAXWINDOW
#define MAXWINDOW 160 /* maximum width window */
#define FAST 2
#define SLOW 1
#define ESC 033
#define UEOF -2 /* user eof char synonym */
#define UINTR -3 /* user intr char synonym */
#define UERASE -4 /* user erase char synonym */
#define UKILL -5 /* user kill char synonym */
#define UWERASE -6 /* user word erase char synonym */
#define ULNEXT -7 /* user next literal char synonym */
#define cntl(x) (x&037)
#ifndef KSHELL
# define STRIP 0377
# define GMACS 1
# define EMACS 2
# define VIRAW 4
# define EDITVI 8
# define NOHIST 16
# define EDITMASK 15
# define is_option(m) (opt_flag&(m))
extern __MANGLE__ char opt_flag;
# ifdef SYSCALL
# define read(fd,buff,n) syscall(3,fd,buff,n)
# else
# define read(fd,buff,n) rEAd(fd,buff,n)
# endif /* SYSCALL */
#endif /* KSHELL */
extern __MANGLE__ struct edit editb;
extern __MANGLE__ void ed_crlf __PROTO__((void));
extern __MANGLE__ void ed_putchar __PROTO__((int));
extern __MANGLE__ void ed_ringbell __PROTO__((void));
extern __MANGLE__ void ed_setup __PROTO__((int));
extern __MANGLE__ void ed_flush __PROTO__((void));
extern __MANGLE__ int ed_getchar __PROTO__((int));
extern __MANGLE__ int ed_virt_to_phys __PROTO__((genchar*,genchar*,int,int,int));
extern __MANGLE__ int ed_window __PROTO__((void));
extern __MANGLE__ void ed_ungetchar __PROTO__((int));
extern __MANGLE__ int ed_viread __PROTO__((int, char*, int));
extern __MANGLE__ int ed_read __PROTO__((int, char*, int));
extern __MANGLE__ int ed_emacsread __PROTO__((int, char*, int));
#ifdef KSHELL
extern __MANGLE__ int ed_macro __PROTO__((int));
extern __MANGLE__ int ed_expand __PROTO__((char[],int*,int*,int));
extern __MANGLE__ int ed_fulledit __PROTO__((void));
#endif /* KSHELL */
# ifdef SHOPT_MULTIBYTE
extern __MANGLE__ int ed_internal __PROTO__((const char*, genchar*));
extern __MANGLE__ int ed_external __PROTO__((const genchar*, char*));
extern __MANGLE__ void ed_gencpy __PROTO__((genchar*,const genchar*));
extern __MANGLE__ void ed_genncpy __PROTO__((genchar*,const genchar*,int));
extern __MANGLE__ int ed_genlen __PROTO__((const genchar*));
extern __MANGLE__ int ed_setwidth __PROTO__((const char*));
# endif /* SHOPT_MULTIBYTE */
extern __MANGLE__ const char e_runvi[];
#ifndef KSHELL
extern __MANGLE__ const char e_version[];
#endif /* KSHELL */
#endif
#endif

View File

@@ -0,0 +1,162 @@
/* $XConsortium: fault.h /main/3 1995/11/01 16:39:48 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SH_SIGBITS
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* UNIX shell
* S. R. Bourne
* Rewritten by David Korn
*
*/
#include <sig.h>
#include <setjmp.h>
#include <error.h>
#include <sfio.h>
#include "FEATURE/setjmp"
#include "FEATURE/sigfeatures"
typedef void (*SH_SIGTYPE) __PROTO__((int,void(*)(int)));
#define SH_FORKLIM 16 /* fork timeout interval */
#define SH_TRAP 0200 /* bit for internal traps */
#define SH_ERRTRAP 0 /* trap for non-zero exit status */
#define SH_KEYTRAP 1 /* trap for keyboard event */
#define SH_DEBUGTRAP 4 /* must be last internal trap */
#define SH_SIGBITS 8
#define SH_SIGFAULT 1 /* signal handler is sh_fault */
#define SH_SIGOFF 2 /* signal handler is SIG_IGN */
#define SH_SIGSET 4 /* pending signal */
#define SH_SIGTRAP 010 /* pending trap */
#define SH_SIGDONE 020 /* default is exit */
#define SH_SIGIGNORE 040 /* default is ingore signal */
#define SH_SIGINTERACTIVE 0100 /* handle interactive specially */
#define SH_SIGTSTP 0200 /* tstp signal received */
/*
* These are longjmp values
*/
#define SH_JMPDOT 2
#define SH_JMPEVAL 3
#define SH_JMPTRAP 4
#define SH_JMPIO 5
#define SH_JMPCMD 6
#define SH_JMPFUN 7
#define SH_JMPERRFN 8
#define SH_JMPSUB 9
#define SH_JMPERREXIT 10
#define SH_JMPEXIT 11
#define SH_JMPSCRIPT 12
struct openlist
{
Sfio_t *strm;
struct openlist *next;
};
struct checkpt
{
sigjmp_buf buff;
sigjmp_buf *prev;
int topfd;
int mode;
struct openlist *olist;
struct errorcontext err;
};
#define sh_pushcontext(bp,n) ( (bp)->mode=(n) , (bp)->olist=0, \
(bp)->topfd=sh.topfd, (bp)->prev=sh.jmplist, \
(bp)->err = *ERROR_CONTEXT_BASE, \
sh.jmplist = (sigjmp_buf*)(bp) \
)
#define sh_popcontext(bp) (sh.jmplist=(bp)->prev, errorpop(&((bp)->err)))
extern __MANGLE__ void sh_fault __PROTO__((int));
extern __MANGLE__ void sh_done __PROTO__((int));
extern __MANGLE__ void sh_chktrap __PROTO__((void));
extern __MANGLE__ void sh_exit __PROTO__((int));
extern __MANGLE__ void sh_sigclear __PROTO__((int));
extern __MANGLE__ void sh_sigdone __PROTO__((void));
extern __MANGLE__ void sh_siginit __PROTO__((void));
extern __MANGLE__ void sh_sigtrap __PROTO__((int));
extern __MANGLE__ void sh_sigreset __PROTO__((int));
extern __MANGLE__ void sh_timetraps __PROTO__((void));
extern __MANGLE__ __V_ *timeradd __PROTO__((unsigned long,int ,void (*)(__V_*),__V_*));
extern __MANGLE__ void timerdel __PROTO__((__V_*));
extern __MANGLE__ const char e_alarm[];
#endif /* !SH_SIGBITS */

View File

@@ -0,0 +1,111 @@
/* $XConsortium: fcin.h /main/3 1995/11/01 16:40:02 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef fcgetc
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* David Korn
* AT&T Bell Laboratories
*
* Fast character input with sfio text streams and strings
*
*/
#include <sfio.h>
typedef struct _fcin
{
Sfio_t *_fcfile; /* input file pointer */
unsigned char *fcbuff; /* pointer to input buffer */
unsigned char *fclast; /* pointer to end of input buffer */
unsigned char *fcptr; /* pointer to next input char */
unsigned char fcchar; /* saved character */
void (*fcfun) __PROTO__((Sfio_t*,const char*,int)); /* advance function */
} Fcin_t;
#define fcfile() (_Fcin._fcfile)
#define fcgetc(c) (((c=fcget()) || (c=fcfill())), c)
#define fcget() ((int)(*_Fcin.fcptr++))
#define fcpeek(n) ((int)_Fcin.fcptr[n])
#define fcseek(n) ((char*)(_Fcin.fcptr+=(n)))
#define fcfirst() ((char*)_Fcin.fcbuff)
#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
#define fcsave(x) (*(x) = _Fcin)
#define fcrestore(x) (_Fcin = *(x))
extern __MANGLE__ int fcfill __PROTO__((void));
extern __MANGLE__ int fcfopen __PROTO__((Sfio_t*));
extern __MANGLE__ int fcclose __PROTO__((void));
void fcnotify __PROTO__((void(*)(Sfio_t*,const char*,int)));
extern __MANGLE__ Fcin_t _Fcin; /* used by macros */
#endif /* fcgetc */

View File

@@ -0,0 +1,129 @@
/* $XConsortium: history.h /main/3 1995/11/01 16:40:17 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef HIST_VERSION
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* Interface for history mechanism
* written by David Korn
*
*/
#include <ast.h>
#include <sfio.h>
#define HIST_CHAR '!'
#define HIST_VERSION 1 /* history file format version no. */
typedef struct
{
Sfdisc_t histdisc; /* discipline for history */
Sfio_t *histfp; /* history file stream pointer */
char *histname; /* name of history file */
long histind; /* current command number index */
int histsize; /* number of accessible history lines */
#ifdef _HIST_PRIVATE
_HIST_PRIVATE
#endif /* _HIST_PRIVATE */
} History_t;
typedef struct
{
int hist_command;
int hist_line;
int hist_char;
} Histloc_t;
/* the following are readonly */
extern __MANGLE__ const char hist_fname[];
extern __MANGLE__ int _Hist;
#define hist_min(hp) ((_Hist=((int)((hp)->histind-(hp)->histsize)))>=0?_Hist:0)
#define hist_max(hp) ((int)((hp)->histind))
/* these are the history interface routines */
extern __MANGLE__ int sh_histinit __PROTO__((void));
extern __MANGLE__ void hist_cancel __PROTO__((History_t*));
extern __MANGLE__ void hist_close __PROTO__((History_t*));
extern __MANGLE__ int hist_copy __PROTO__((char*, int, int, int));
extern __MANGLE__ void hist_eof __PROTO__((History_t*));
extern __MANGLE__ Histloc_t hist_find __PROTO__((History_t*,char*,int, int, int));
extern __MANGLE__ void hist_flush __PROTO__((History_t*));
extern __MANGLE__ void hist_list __PROTO__((History_t*,Sfio_t*, off_t, int, char*));
extern __MANGLE__ int hist_match __PROTO__((History_t*,off_t, char*, int*));
extern __MANGLE__ off_t hist_tell __PROTO__((History_t*,int));
extern __MANGLE__ off_t hist_seek __PROTO__((History_t*,int));
extern __MANGLE__ char *hist_word __PROTO__((char*, int, int));
#ifdef SHOPT_ESH
extern __MANGLE__ Histloc_t hist_locate __PROTO__((History_t*,int, int, int));
#endif /* SHOPT_ESH */
#endif /* HIST_VERSION */

View File

@@ -0,0 +1,138 @@
/* $XConsortium: io.h /main/3 1995/11/01 16:40:32 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include <sfio.h>
#ifndef IOBSIZE
# define IOBSIZE 1024
#endif /* IOBSIZE */
#define IOMAXTRY 20
/* used for output of shell errors */
#define ERRIO 2
#define IOREAD 001
#define IOWRITE 002
#define IODUP 004
#define IOSEEK 010
#define IONOSEEK 020
#define IOTTY 040
#define IOCLEX 0100
#define IOCLOSE (IOSEEK|IONOSEEK)
/*
* The remainder of this file is only used when compiled with shell
*/
#ifdef KSHELL
#define sh_inuse(f2) (sh.fdptrs[f2])
extern __MANGLE__ int sh_iocheckfd __PROTO__((int));
extern __MANGLE__ void sh_ioinit __PROTO__((void));
extern __MANGLE__ int sh_iomovefd __PROTO__((int));
extern __MANGLE__ int sh_iorenumber __PROTO__((int,int));
extern __MANGLE__ void sh_pclose __PROTO__((int[]));
extern __MANGLE__ void sh_iorestore __PROTO__((int));
extern __MANGLE__ Sfio_t *sh_iostream __PROTO__((int));
struct ionod;
extern __MANGLE__ int sh_redirect __PROTO__((struct ionod*,int));
extern __MANGLE__ void sh_iosave __PROTO__((int,int));
extern __MANGLE__ void sh_iounsave __PROTO__((void));
extern __MANGLE__ int sh_chkopen __PROTO__((const char*));
extern __MANGLE__ int sh_ioaccess __PROTO__((int,int));
/* the following are readonly */
extern __MANGLE__ const char e_pexists[];
extern __MANGLE__ const char e_query[];
extern __MANGLE__ const char e_history[];
extern __MANGLE__ const char e_argtype[];
extern __MANGLE__ const char e_create[];
extern __MANGLE__ const char e_tmpcreate[];
extern __MANGLE__ const char e_exists[];
extern __MANGLE__ const char e_file[];
extern __MANGLE__ const char e_formspec[];
extern __MANGLE__ const char e_badregexp[];
extern __MANGLE__ const char e_open[];
extern __MANGLE__ const char e_toomany[];
extern __MANGLE__ const char e_pipe[];
extern __MANGLE__ const char e_flimit[];
extern __MANGLE__ const char e_unknown[];
extern __MANGLE__ const char e_devnull[];
extern __MANGLE__ const char e_profile[];
extern __MANGLE__ const char e_sysprofile[];
extern __MANGLE__ const char e_stdprompt[];
extern __MANGLE__ const char e_supprompt[];
extern __MANGLE__ const char e_ambiguous[];
#endif /* KSHELL */

View File

@@ -0,0 +1,204 @@
/* $XConsortium: jobs.h /main/3 1995/11/01 16:40:45 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef JOB_NFLAG
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* Interface to job control for shell
* written by David Korn
*
*/
#define JOBTTY 2
#include <ast.h>
#include <sfio.h>
#ifndef SIGINT
# include <signal.h>
#endif /* !SIGINT */
#include "FEATURE/options"
#undef JOBS
#if defined(SIGCLD) && !defined(SIGCHLD)
# define SIGCHLD SIGCLD
#endif
#ifdef SIGCHLD
# define JOBS 1
# include "terminal.h"
# ifdef FIOLOOKLD
/* Ninth edition */
extern __MANGLE__ int tty_ld, ntty_ld;
# define OTTYDISC tty_ld
# define NTTYDISC ntty_ld
# endif /* FIOLOOKLD */
#else
# undef SIGTSTP
# undef SH_MONITOR
# define SH_MONITOR 0
# define job_set(x)
# define job_reset(x)
#endif
struct process
{
struct process *p_nxtjob; /* next job structure */
struct process *p_nxtproc; /* next process in current job */
pid_t p_pid; /* process id */
pid_t p_pgrp; /* process group */
pid_t p_fgrp; /* process group when stopped */
short p_job; /* job number of process */
unsigned short p_exit; /* exit value or signal number */
unsigned char p_flag; /* flags - see below */
int p_env; /* subshell environment number */
#ifdef JOBS
off_t p_name; /* history file offset for command */
struct termios p_stty; /* terminal state for job */
#endif /* JOBS */
};
struct jobs
{
struct process *pwlist; /* head of process list */
pid_t curpgid; /* current process gid id */
pid_t parent; /* set by fork() */
pid_t mypid; /* process id of shell */
pid_t mypgid; /* process group id of shell */
pid_t mytgid; /* terminal group id of shell */
int numpost; /* number of posted jobs */
short fd; /* tty descriptor number */
#ifdef JOBS
int suspend; /* suspend character */
int linedisc; /* line dicipline */
#endif /* JOBS */
char in_critical; /* set when in critical region */
char jobcontrol; /* turned on for real job control */
char waitsafe; /* wait will not block */
char waitall; /* wait for all jobs in pipe */
char toclear; /* job table needs clearing */
unsigned char *freejobs; /* free jobs numbers */
};
/* flags for joblist */
#define JOB_LFLAG 1
#define JOB_NFLAG 2
#define JOB_PFLAG 4
#define JOB_NLFLAG 8
extern __MANGLE__ struct jobs job;
#ifdef JOBS
extern __MANGLE__ const char e_jobusage[];
extern __MANGLE__ const char e_kill[];
extern __MANGLE__ const char e_done[];
extern __MANGLE__ const char e_running[];
extern __MANGLE__ const char e_coredump[];
extern __MANGLE__ const char e_killcolon[];
extern __MANGLE__ const char e_no_proc[];
extern __MANGLE__ const char e_no_job[];
extern __MANGLE__ const char e_jobsrunning[];
extern __MANGLE__ const char e_nlspace[];
extern __MANGLE__ const char e_access[];
extern __MANGLE__ const char e_terminate[];
extern __MANGLE__ const char e_no_jctl[];
#ifdef SIGTSTP
extern __MANGLE__ const char e_no_start[];
#endif /* SIGTSTP */
#ifdef NTTYDISC
extern __MANGLE__ const char e_newtty[];
extern __MANGLE__ const char e_oldtty[];
#endif /* NTTYDISC */
#endif /* JOBS */
/*
* The following are defined in jobs.c
*/
extern __MANGLE__ void job_clear __PROTO__((void));
extern __MANGLE__ void job_bwait __PROTO__((char**));
extern __MANGLE__ int job_walk __PROTO__((Sfio_t*,int(*)(struct process*,int),int,char*[]));
extern __MANGLE__ int job_kill __PROTO__((struct process*,int));
extern __MANGLE__ void job_wait __PROTO__((pid_t));
extern __MANGLE__ int job_post __PROTO__((pid_t,pid_t));
extern __MANGLE__ int job_chksave __PROTO__((pid_t));
#ifdef JOBS
extern __MANGLE__ void job_init __PROTO__((int));
extern __MANGLE__ int job_close __PROTO__((void));
extern __MANGLE__ int job_list __PROTO__((struct process*,int));
extern __MANGLE__ int job_terminate __PROTO__((struct process*,int));
extern __MANGLE__ int job_switch __PROTO__((struct process*,int));
#else
# define job_init(flag)
# define job_close() (0)
#endif /* JOBS */
#endif /* !JOB_NFLAG */

View File

@@ -0,0 +1,166 @@
/* $XConsortium: lexstates.h /main/3 1995/11/01 16:40:59 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef S_BREAK
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define S_BREAK 1 /* end of token */
#define S_EOF 2 /* end of buffer */
#define S_NL 3 /* new-line when not a token */
#define S_RES 4 /* first character of reserved word */
#define S_NAME 5 /* other identifier characters */
#define S_REG 6 /* non-special characters */
#define S_TILDE 7 /* first char is tilde */
#define S_PUSH 8
#define S_POP 9
#define S_BRACT 10
#define S_LIT 11 /* literal quote character */
#define S_NLTOK 12 /* new-line token */
#define S_OP 13 /* operator character */
#define S_PAT 14 /* pattern characters * and ? */
#define S_EPAT 15 /* pattern char when followed by ( */
#define S_EQ 16 /* assignment character */
#define S_COM 17 /* comment character */
#define S_MOD1 18 /* ${...} modifier character - old quoting */
#define S_MOD2 19 /* ${...} modifier character - new quoting */
#define S_ERR 20 /* invalid character in ${...} */
#define S_SPC1 21 /* special prefix characters after $ */
#define S_SPC2 22 /* special characters after $ */
#define S_DIG 23 /* digit character after $*/
#define S_ALP 24 /* alpahbetic character after $ */
#define S_LBRA 25 /* left brace after $ */
#define S_RBRA 26 /* right brace after $ */
#define S_PAR 27 /* set for $( */
#define S_ENDCH 28 /* macro expansion terminator */
#define S_SLASH 29 /* / character terminates ~ expansion */
#define S_COLON 30 /* for character : */
#define S_LABEL 31 /* for goto label */
#define S_EDOL 32 /* ends $identifier */
#define S_BRACE 33 /* left brace */
#define S_DOT 34 /* . char */
#define S_META 35 /* | & ; < > inside ${...} reserved for future use */
#define S_SPACE S_BREAK /* IFS space characters */
#define S_DELIM S_RES /* IFS delimter characters */
#define S_MBYTE S_NAME /* IFS first byte of multi-byte char */
/* The following must be the highest numbered states */
#define S_QUOTE 36 /* double quote character */
#define S_GRAVE 37 /* old comsub character */
#define S_ESC 38 /* escape character */
#define S_DOL 39 /* $ subsitution character */
#define S_ESC2 40 /* escape character inside '...' */
/* These are the lexical state table names */
#define ST_BEGIN 0
#define ST_NAME 1
#define ST_NORM 2
#define ST_LIT 3
#define ST_QUOTE 4
#define ST_NESTED 5
#define ST_DOL 6
#define ST_BRACE 7
#define ST_DOLNAME 8
#define ST_MACRO 9
#define ST_QNEST 10
#define ST_NONE 11
#define isaname(c) (sh_lexstates[ST_NAME][c]==0)
#define isadigit(c) (sh_lexstates[ST_DOL][c]==S_DIG)
#define isaletter(c) (sh_lexstates[ST_DOL][c]==S_ALP && (c)!='.')
#define isastchar(c) ((c)=='@' || (c)=='*')
#define isexp(c) (sh_lexstates[ST_MACRO][c]==S_PAT||(c)=='$'||(c)=='`')
#define ismeta(c) (sh_lexstates[ST_NAME][c]==S_BREAK)
extern __MANGLE__ char *sh_lexstates[ST_NONE];
extern __MANGLE__ const char *sh_lexrstates[ST_NONE];
extern __MANGLE__ const char e_lexversion[];
extern __MANGLE__ const char e_lexspace[];
extern __MANGLE__ const char e_lexslash[];
extern __MANGLE__ const char e_lexlabignore[];
extern __MANGLE__ const char e_lexlabunknown[];
extern __MANGLE__ const char e_lexsyntax1[];
extern __MANGLE__ const char e_lexsyntax2[];
extern __MANGLE__ const char e_lexsyntax3[];
extern __MANGLE__ const char e_lexobsolete1[];
extern __MANGLE__ const char e_lexobsolete2[];
extern __MANGLE__ const char e_lexobsolete3[];
extern __MANGLE__ const char e_lexobsolete4[];
extern __MANGLE__ const char e_lexobsolete5[];
extern __MANGLE__ const char e_lexobsolete6[];
extern __MANGLE__ const char e_lexusebrace[];
extern __MANGLE__ const char e_lexusequote[];
extern __MANGLE__ const char e_lexescape[];
extern __MANGLE__ const char e_lexquote[];
extern __MANGLE__ const char e_lexnested[];
extern __MANGLE__ const char e_lexbadchar[];
extern __MANGLE__ const char e_lexlongquote[];
extern __MANGLE__ const char e_lexfuture[];
extern __MANGLE__ const char e_lexzerobyte[];
#endif

View File

@@ -0,0 +1,204 @@
/* $XConsortium: name.h /main/3 1995/11/01 16:41:17 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef _NV_PRIVATE
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* This is the implementation header file for name-value pairs
*/
#define _NV_PRIVATE \
union Value nvalue; /* value field */ \
char *nvenv; /* pointer to environment name */ \
Namfun_t *nvfun; /* pointer to trap functions */
#include <ast.h>
#include "shtable.h"
/* Nodes can have all kinds of values */
union Value
{
const char *cp;
int *ip;
char c;
int i;
unsigned u;
long *lp;
short s;
double *dp; /* for floating point arithmetic */
struct Namarray *array; /* for array node */
struct Namval *np; /* for Namval_t node */
union Value *up; /* for indirect node */
struct Ufunction *rp; /* shell user defined functions */
int (*bfp) __PROTO__((int,char*[],__V_*));/* builtin entry point function pointer */
};
#include "nval.h"
/* used for arrays */
#define ARRAY_MASK ((1L<<ARRAY_BITS)-1) /* For index values */
#define ARRAY_MAX 4096 /* maximum number of elements in an array
This must be less than ARRAY_MASK */
#define ARRAY_INCR 16 /* number of elements to grow when array
bound exceeded. Must be a power of 2 */
/* These flags are used as options to array_get() */
#define ARRAY_ASSIGN 0
#define ARRAY_LOOKUP 1
#define ARRAY_DELETE 2
/* This describes a user shell function node */
struct Ufunction
{
int *ptree; /* address of parse tree */
int lineno; /* line number of function start */
off_t hoffset; /* offset into history file */
};
/* attributes of Namval_t items */
/* The following attributes are for internal use */
#define NV_IMPORT NV_NOADD /* value imported from environment */
#define NV_FUNCT NV_IDENT /* node value points to function */
#define NV_NOCHANGE (NV_EXPORT|NV_IMPORT|NV_RDONLY|NV_TAGGED|NV_NOFREE)
#define NV_ATTRIBUTES (~(NV_NOSCOPE|NV_ARRAY|NV_IDENT|NV_ASSIGN|NV_REF|NV_VARNAME))
#define NV_HOST (NV_RJUST|NV_LJUST)
#define NV_PARAM (1<<12) /* expansion use positional params */
/* This following are for use with nodes which are not name-values */
#define NV_FUNCTION (NV_RJUST|NV_FUNCT) /* value is shell function */
#define NV_FPOSIX NV_LJUST /* posix function semantics */
#define NV_NOPRINT (NV_LTOU|NV_UTOL) /* do not print */
#define NV_NOALIAS (NV_NOPRINT|NV_IMPORT)
#define NV_NOEXPAND NV_RJUST /* do not expand alias */
#define NV_BLTIN (NV_NOPRINT|NV_EXPORT)
#define BLT_ENV (NV_RDONLY) /* non-stoppable,
* can modify enviornment */
#define BLT_SPC (NV_LJUST) /* special built-ins */
#define BLT_EXIT (NV_RJUST) /* exit value can be > 255 */
#define BLT_DCL (NV_TAGGED) /* declaration command */
#define is_abuiltin(n) (nv_isattr(n,NV_BLTIN)==NV_BLTIN)
#define is_afunction(n) (nv_isattr(n,NV_FUNCTION)==NV_FUNCTION)
#define nv_funtree(n) ((n)->nvalue.rp->ptree)
#define funptr(n) ((n)->nvalue.bfp)
/* NAMNOD MACROS */
#define nv_link(root,n) hashlook((Hashtab_t*)(root),(char*)(n),\
HASH_INSTALL,(char*)sizeof(Namval_t))
/* ... for attributes */
#define nv_onattr(n,f) ((n)->nvflag |= (f))
#define nv_setattr(n,f) ((n)->nvflag = (f))
#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
/* ... etc */
#define nv_setsize(n,s) ((n)->nvsize = ((s)&0xfff))
/* ... for arrays */
#define nv_arrayptr(np) (nv_isattr(np,NV_ARRAY)?(np)->nvalue.array:(Namarr_t*)0)
#define array_elem(ap) ((ap)->nelem&ARRAY_MASK)
#define array_assoc(ap) ((ap)->fun)
extern __MANGLE__ void array_check __PROTO__((Namval_t*, int));
extern __MANGLE__ union Value *array_find __PROTO__((Namval_t*, int));
extern __MANGLE__ char *nv_endsubscript __PROTO__((Namval_t*, char*, int));
extern __MANGLE__ Namfun_t *nv_cover __PROTO__((Namval_t*));
struct argnod; /* struct not declared yet */
extern __MANGLE__ void nv_setlist __PROTO__((struct argnod*, int));
extern __MANGLE__ void nv_scope __PROTO__((struct argnod*));
extern __MANGLE__ const char e_subscript[];
extern __MANGLE__ const char e_nullset[];
extern __MANGLE__ const char e_notset[];
extern __MANGLE__ const char e_noparent[];
extern __MANGLE__ const char e_readonly[];
extern __MANGLE__ const char e_badfield[];
extern __MANGLE__ const char e_restricted[];
extern __MANGLE__ const char e_ident[];
extern __MANGLE__ const char e_varname[];
extern __MANGLE__ const char e_funname[];
extern __MANGLE__ const char e_intbase[];
extern __MANGLE__ const char e_noalias[];
extern __MANGLE__ const char e_aliname[];
extern __MANGLE__ const char e_badexport[];
extern __MANGLE__ const char e_badref[];
extern __MANGLE__ const char e_noref[];
extern __MANGLE__ const char e_selfref[];
extern __MANGLE__ const char e_envmarker[];
extern __MANGLE__ const char e_badlocale[];
extern __MANGLE__ const char e_loop[];
#endif /* _NV_PRIVATE */

View File

@@ -0,0 +1,116 @@
/* $XConsortium: national.h /main/3 1995/11/01 16:41:38 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#ifdef SHOPT_MULTIBYTE
/*
* This data must be defined for each country in defs.c
*/
#ifndef HIGHBIT
# define HIGHBIT (1<<(CHAR_BIT-1))
#endif /* HIGHBIT */
#ifndef ESS_MAXCHAR /* allow multiple includes */
/*
* This section may change from country to country
*/
#define ESS_MAXCHAR 2 /* Maximum number of non-escape bytes
for any and all character sets */
#define CCS1_IN_SIZE 2
#define CCS1_OUT_SIZE 2
#define CCS2_IN_SIZE 1
#define CCS2_OUT_SIZE 1
#define CCS3_IN_SIZE 2
#define CCS3_OUT_SIZE 2
/*
* This part is generic
*/
#define MARKER 0x100 /* Must be invalid character */
#define ESS2 0x8e /* Escape to char set 2 */
#define ESS3 0x8f /* Escape to char set 3 */
#define ESS_SETMASK (3<<(7*ESS_MAXCHAR)) /* character set bits */
#define echarset(c) ((c)==ESS3?3:((c)==ESS2)?2:((c)>>7)&1)
#define icharset(i) ((i)>>(7*ESS_MAXCHAR)&3)
#define in_csize(s) int_charsize[s]
#define out_csize(s) int_charsize[s+4]
extern __MANGLE__ char int_charsize[8];
extern __MANGLE__ int sh_strchr __PROTO__((const char*,const char*));
#endif /* ESS_MAXCHAR */
#endif /* SHOPT_MULTIBYTE */

View File

@@ -0,0 +1,258 @@
/* $XConsortium: nval.h /main/3 1995/11/01 16:41:55 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef NV_DEFAULT
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* David Korn
* AT&T Bell Laboratories
*
* Interface definitions of structures for name-value pairs
* These structures are used for named variables, functions and aliases
*
*/
#include <ast.h>
#include <hash.h>
typedef struct Namval Namval_t;
typedef struct Namfun Namfun_t;
typedef struct Namdisc Namdisc_t;
typedef struct Namarray Namarr_t;
/*
* This defines the template for nodes that have their own assignment
* and or lookup functions
*/
struct Namdisc
{
size_t dsize;
void (*putval) __PROTO__((Namval_t*, const char*, int, Namfun_t*));
char *(*getval) __PROTO__((Namval_t*, Namfun_t*));
double (*getnum) __PROTO__((Namval_t*, Namfun_t*));
char *(*setdisc) __PROTO__((Namval_t*, const char*, Namval_t*, Namfun_t*));
Namval_t *(*create) __PROTO__((Namval_t*, const char*, Namfun_t*));
char *(*name) __PROTO__((Namval_t*, Namfun_t*));
int (*scope) __PROTO__((Namval_t*, Namval_t*, int, Namfun_t*));
};
struct Namfun
{
const Namdisc_t *disc;
Namfun_t *next;
};
/* This is an array template header */
struct Namarray
{
long nelem; /* number of elements */
__V_ *(*fun) __PROTO__((Namval_t*,const char*,int)); /* associative arrays */
};
/* attributes of name-value node attribute flags */
#define NV_DEFAULT 0
/* This defines the attributes for an attributed name-value pair node */
struct Namval
{
HASH_HEADER; /* space for hash library */
unsigned short nvflag; /* attributes */
short nvsize; /* size of item */
#ifdef _NV_PRIVATE
_NV_PRIVATE
#else /* hopefully these will become private soon */
char *nvalue;
char *nvenv; /* pointer to environment name */
Namfun_t *nvfun; /* pointer to trap disciplines */
#endif /* _NV_PRIVATE */
char *nvdtenv; /* dtksh-specific environment name */
};
/* The following attributes are for internal use */
#define NV_NOALLOC 0x100 /* don't allocate space for the value */
#define NV_NOFREE 0x200 /* don't free the space when releasing value */
#define NV_ARRAY 0x400 /* node is an array */
#define NV_INTEGER 0x2 /* integer attribute */
/* The following attributes are valid only when NV_INTEGER is off */
#define NV_LTOU 0x4 /* convert to uppercase */
#define NV_UTOL 0x8 /* convert to lowercase */
#define NV_ZFILL 0x10 /* right justify and fill with leading zeros */
#define NV_RJUST 0x20 /* right justify and blank fill */
#define NV_LJUST 0x40 /* left justify and blank fill */
/* The following attributes do not effect the value */
#define NV_RDONLY 0x1 /* readonly bit */
#define NV_EXPORT 0x2000 /* export bit */
#define NV_REF 0x4000 /* reference bit */
#define NV_TAGGED 0x8000 /* user define tag bit */
/* The following are used with NV_INTEGER */
#define NV_SHORT (NV_LTOU) /* when integers are not long */
#define NV_UNSIGN (NV_UTOL) /* for unsigned quantities */
#define NV_DOUBLE (NV_ZFILL) /* for floating point */
#define NV_EXPNOTE (NV_LTOU) /* for scientific notation */
#define NV_CPOINTER (NV_RJUST) /* for pointer */
/* options for nv_open */
#ifdef _NV_PRIVATE
# define NV_ADD (HASH_CREATE|HASH_SIZE((long)sizeof(Namval_t)))
#else
# define NV_ADD (HASH_CREATE|HASH_SIZE((long)sizeof(Namval_t))+2*sizeof(char*))
#endif /* _NV_PRIVATE */
/* add node if not found */
#define NV_NOSCOPE NV_NOALLOC /* look only in current scope */
#define NV_ASSIGN NV_NOFREE /* assignment is possible */
#define NV_NOASSIGN 0 /* backward compatibility */
#define NV_NOARRAY NV_ARRAY /* array name not possible */
#define NV_NOREF NV_REF /* don't follow reference */
#define NV_IDENT 0x80 /* name must be identifier */
#define NV_VARNAME 0x800 /* name must be ?(.)id*(.id) */
#define NV_NOADD 0x1000 /* do not add node */
#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
/* name-value pair macros */
#define nv_isattr(np,f) ((np)->nvflag & (f))
#ifdef _NV_PRIVATE
# define nv_isnull(np) (!(np)->nvalue.cp && !(np)->nvfun) /* strings only */
#else
# define nv_isnull(np) (!(np)->nvalue && !(np)->nvfun) /* strings only */
#endif /* _NV_PRIVATE */
#define nv_name(np) hashname((Hashbin_t*)(np))
#define nv_size(np) ((np)->nvsize&0xfff)
#define nv_unscope() (sh.var_tree = hashfree(sh.var_tree))
#define nv_search(name,root,mode) ((Namval_t*)hashlook((Hashtab_t*)(root),name,(mode)^HASH_SCOPE,(char*)0))
#ifdef SHOPT_OO
# define nv_class(np) (nv_isattr(np,NV_IMPORT)?0:(Namval_t*)((np)->nvenv))
#endif /* SHOPT_OO */
/* The following are operations for associative arrays */
#define NV_AINIT 1 /* initialize */
#define NV_AFREE 2 /* free array */
#define NV_ANEXT 3 /* advance to next subscript */
#define NV_ANAME 4 /* return subscript name */
#define NV_ADELETE 5 /* delete current subscript */
#define NV_AADD 6 /* add subscript if not found */
/* The following are operations for nv_putsub() */
#define ARRAY_BITS 16
#define ARRAY_ADD (1L<<ARRAY_BITS) /* add subscript if not found */
#define ARRAY_SCAN (2L<<ARRAY_BITS) /* For ${array[@]} */
#define ARRAY_UNDEF (4L<<ARRAY_BITS) /* For ${array} */
/* prototype for array interface*/
extern __MANGLE__ Namarr_t *nv_setarray __PROTO__((Namval_t*,__V_*(*)(Namval_t*,const char*,int)));
extern __MANGLE__ __V_ *nv_associative __PROTO__((Namval_t*,const char*,int));
extern __MANGLE__ int nv_aindex __PROTO__((Namval_t*));
extern __MANGLE__ int nv_nextsub __PROTO__((Namval_t*));
extern __MANGLE__ char *nv_getsub __PROTO__((Namval_t*));
extern __MANGLE__ Namval_t *nv_putsub __PROTO__((Namval_t*, char*, long));
/* name-value pair function prototypes */
extern __MANGLE__ void nv_close __PROTO__((Namval_t*));
extern __MANGLE__ Namval_t *nv_create __PROTO__((Namval_t*,const char*,Namfun_t*));
extern __MANGLE__ double nv_getn __PROTO__((Namval_t*, Namfun_t*));
extern __MANGLE__ double nv_getnum __PROTO__((Namval_t*));
extern __MANGLE__ Hashtab_t *nv_getscope __PROTO__((int));
extern __MANGLE__ char *nv_getv __PROTO__((Namval_t*, Namfun_t*));
extern __MANGLE__ char *nv_getval __PROTO__((Namval_t*));
extern __MANGLE__ void nv_newattr __PROTO__((Namval_t*,unsigned,int));
extern __MANGLE__ Namval_t *nv_open __PROTO__((const char*,Hashtab_t*,int));
extern __MANGLE__ void nv_putval __PROTO__((Namval_t*,const char*,int));
extern __MANGLE__ void nv_putv __PROTO__((Namval_t*,const char*,int,Namfun_t*));
extern __MANGLE__ int nv_scan __PROTO__((Hashtab_t*,void(*)(Namval_t*),int,int));
extern __MANGLE__ Namval_t *nv_scoped __PROTO__((Namval_t*));
extern __MANGLE__ char *nv_setdisc __PROTO__((Namval_t*,const char*,Namval_t*,Namfun_t*));
extern __MANGLE__ void nv_setref __PROTO__((Namval_t*));
extern __MANGLE__ void nv_setvec __PROTO__((Namval_t*,int,char*[]));
extern __MANGLE__ void nv_setvtree __PROTO__((Namval_t*));
extern __MANGLE__ Namfun_t *nv_stack __PROTO__((Namval_t*,Namfun_t*));
extern __MANGLE__ void nv_unset __PROTO__((Namval_t*));
#if 0
/*
* The names of many functions were changed in early '95
* Here is a mapping to the old names
*/
# define nv_istype(np) nv_isattr(np)
# define nv_newtype(np) nv_newattr(np)
# define nv_namset(np,a,b) nv_open(np,a,b)
# define nv_free(np) nv_unset(np)
# define nv_settype(np,a,b,c) nv_setdisc(np,a,b,c)
# define nv_search(np,a,b) nv_open(np,a,((b)?0:NV_NOADD))
# define settype setdisc
#endif
#endif /* NV_DEFAULT */

View File

@@ -0,0 +1,153 @@
/* $XConsortium: path.h /main/3 1995/11/01 16:42:10 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef PATH_OFFSET
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* UNIX shell path handling interface
* Written by David Korn
* These are the definitions for the lexical analyzer
*/
#include "FEATURE/options"
#include <nval.h>
#define PATH_OFFSET 2 /* path offset for path_join */
#define MAXDEPTH (32*sizeof(int)) /* maximum levels of recursion */
struct argnod;
/* pathname handling routines */
extern __MANGLE__ void path_alias __PROTO__((Namval_t*,char*));
extern __MANGLE__ char *path_absolute __PROTO__((const char*,const char*));
extern __MANGLE__ char *path_basename __PROTO__((const char*));
extern __MANGLE__ int path_expand __PROTO__((const char*, struct argnod**));
extern __MANGLE__ void path_exec __PROTO__((const char*,char*[],struct argnod*));
extern __MANGLE__ int path_open __PROTO__((const char*,char*));
extern __MANGLE__ char *path_get __PROTO__((const char*));
extern __MANGLE__ char *path_join __PROTO__((char*,const char*));
extern __MANGLE__ char *path_pwd __PROTO__((int));
extern __MANGLE__ int path_search __PROTO__((const char*,const char*,int));
extern __MANGLE__ char *path_relative __PROTO__((const char*));
extern __MANGLE__ int path_complete __PROTO__((const char*, const char*,struct argnod**));
#ifdef SHOPT_BRACEPAT
extern __MANGLE__ int path_generate __PROTO__((struct argnod*,struct argnod**));
#endif /* SHOPT_BRACEPAT */
/* constant strings needed for whence */
extern __MANGLE__ const char e_real[];
extern __MANGLE__ const char e_user[];
extern __MANGLE__ const char e_sys[];
extern __MANGLE__ const char e_dot[];
extern __MANGLE__ const char e_pwd[];
extern __MANGLE__ const char e_logout[];
extern __MANGLE__ const char e_alphanum[];
extern __MANGLE__ const char e_mailmsg[];
extern __MANGLE__ const char e_suidprofile[];
extern __MANGLE__ const char e_sysprofile[];
extern __MANGLE__ const char e_traceprompt[];
extern __MANGLE__ const char e_crondir[];
#ifdef SHOPT_SUID_EXEC
extern __MANGLE__ const char e_suidexec[];
#endif /* SHOPT_SUID_EXEC */
#ifdef SHOPT_VPIX
extern __MANGLE__ const char e_vpix[];
extern __MANGLE__ const char e_vpixdir[];
#endif /* SHOPT_VPIX */
extern __MANGLE__ const char is_[];
extern __MANGLE__ const char is_alias[];
extern __MANGLE__ const char is_builtin[];
extern __MANGLE__ const char is_builtver[];
extern __MANGLE__ const char is_reserved[];
extern __MANGLE__ const char is_talias[];
extern __MANGLE__ const char is_xalias[];
extern __MANGLE__ const char is_function[];
extern __MANGLE__ const char is_xfunction[];
extern __MANGLE__ const char is_ufunction[];
#ifdef SHELLMAGIC
extern __MANGLE__ const char e_prohibited[];
#endif /* SHELLMAGIC */
#ifdef SHOPT_ACCT
# include "FEATURE/acct"
# ifdef _sys_acct
extern __MANGLE__ void sh_accinit __PROTO__((void));
extern __MANGLE__ void sh_accbegin __PROTO__((const char*));
extern __MANGLE__ void sh_accend __PROTO__((void));
extern __MANGLE__ void sh_accsusp __PROTO__((void));
# else
# undef SHOPT_ACCT
# endif /* _sys_acct */
#endif /* SHOPT_ACCT */
#endif /*! PATH_OFFSET */

View File

@@ -0,0 +1,221 @@
/* $XConsortium: shell.h /main/3 1995/11/01 16:42:28 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SH_INTERACTIVE
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* David Korn
* AT&T Bell Laboratories
*
* Interface definitions for shell command language
*
*/
#include <cmd.h>
#include <hash.h>
#ifdef _SH_PRIVATE
# include "name.h"
#else
# include <nval.h>
#endif /* _SH_PRIVATE */
#undef NOT_USED
#define NOT_USED(x) (&x,1)
/* options */
typedef unsigned long Shopt_t;
#define sh_isoption(x) (sh.options & (x))
#define sh_onoption(x) (sh.options |= (x))
#define sh_offoption(x) (sh.options &= ~(x))
#define SH_CFLAG (1<<0)
#define SH_HISTORY (1<<1) /* used also as a state */
#define SH_ERREXIT (1<<2) /* used also as a state */
#define SH_VERBOSE (1<<3) /* used also as a state */
#define SH_MONITOR (1<<4)/* used also as a state */
#define SH_INTERACTIVE (1<<5) /* used also as a state */
#define SH_RESTRICTED (1L<<6)
#define SH_XTRACE (1L<<7)
#define SH_KEYWORD (1L<<8)
#define SH_NOUNSET (1L<<9)
#define SH_NOGLOB (1L<<10)
#define SH_ALLEXPORT (1L<<11)
#define SH_IGNOREEOF (1L<<13)
#define SH_NOCLOBBER (1L<<14)
#define SH_MARKDIRS (1L<<15)
#define SH_BGNICE (1L<<16)
#define SH_VI (1L<<17)
#define SH_VIRAW (1L<<18)
#define SH_TFLAG (1L<<19)
#define SH_TRACKALL (1L<<20)
#define SH_SFLAG (1L<<21)
#define SH_NOEXEC (1L<<22)
#define SH_GMACS (1L<<24)
#define SH_EMACS (1L<<25)
#define SH_PRIVILEGED (1L<<26)
#define SH_PHYSICAL (1L<<27)
#define SH_NOLOG (1L<<28)
#define SH_NOTIFY (1L<<29)
#define SH_DICTIONARY (1L<<30)
/* The following type is used for error messages */
/* error messages */
extern __MANGLE__ const char e_defpath[];
extern __MANGLE__ const char e_found[];
extern __MANGLE__ const char e_nospace[];
extern __MANGLE__ const char e_format[];
extern __MANGLE__ const char e_number[];
extern __MANGLE__ const char e_restricted[];
extern __MANGLE__ const char e_version[];
extern __MANGLE__ const char e_recursive[];
/*
* Saves the state of the shell
*/
typedef struct sh_static
{
int inlineno;
Sfio_t *heredocs; /* current here-doc file */
Shopt_t options;
Hashtab_t *var_tree; /* for shell variables */
Hashtab_t *fun_tree; /* for shell functions */
Hashtab_t *alias_tree; /* for alias names */
Namval_t *bltin_nodes; /* pointer to built-in variables */
int **fdptrs; /* pointer to file numbers */
Sfio_t **sftable; /* pointer to stream pointer table */
unsigned char *fdstatus; /* pointer to file status table */
int subshell; /* set for virtual subshell */
unsigned int trapnote;
char *lastpath; /* last alsolute path found */
int exitval;
char *lastarg;
const char *pwd; /* present working directory */
int savexit;
#ifdef _SH_PRIVATE
_SH_PRIVATE
#endif /* _SH_PRIVATE */
} Shell_t;
/* flags for sh_parse */
#define SH_NL 1 /* Treat new-lines as ; */
#define SH_EOF 2 /* EOF causes syntax error */
extern __MANGLE__ void sh_subfork __PROTO__((void));
extern __MANGLE__ int sh_init __PROTO__((int,char*[]));
extern __MANGLE__ int sh_eval __PROTO__((Sfio_t*,int));
extern __MANGLE__ void sh_delay __PROTO__((double));
extern __MANGLE__ union anynode *sh_parse __PROTO__((Sfio_t*,int));
extern __MANGLE__ int sh_trap __PROTO__((const char*,int));
extern __MANGLE__ int sh_fun __PROTO__((Namval_t*,Namval_t*));
extern __MANGLE__ void sh_menu __PROTO__((Sfio_t*, int, char*[]));
extern __MANGLE__ int sh_addbuiltin __PROTO__((const char*, int(*)(int, char*[],__V_*), __V_*));
extern __MANGLE__ char *sh_fmtq __PROTO__((const char*));
extern __MANGLE__ double sh_strnum __PROTO__((const char*, char**));
extern __MANGLE__ int sh_access __PROTO__((const char*,int));
extern __MANGLE__ int sh_close __PROTO__((int));
extern __MANGLE__ void sh_exit __PROTO__((int));
extern __MANGLE__ int sh_open __PROTO__((const char*, int, ...));
extern __MANGLE__ ssize_t sh_read __PROTO__((int, __V_*, size_t));
extern __MANGLE__ ssize_t sh_write __PROTO__((int, const __V_*, size_t));
extern __MANGLE__ off_t sh_seek __PROTO__((int, off_t, int));
extern __MANGLE__ int sh_pipe __PROTO__((int[]));
extern __MANGLE__ int sh_waitevent __PROTO__((int));
#ifdef SHOPT_DYNAMIC
extern __MANGLE__ __V_ **sh_getliblist __PROTO__((void));
#endif /* SHOPT_DYNAMIC */
#ifndef _SH_PRIVATE
# define access(a,b) sh_access(a,b)
# define close(a) sh_close(a)
# define exit(a) sh_exit(a)
# define pipe(a) sh_pipe(a)
# define read(a,b,c) sh_read(a,b,c)
# define write(a,b,c) sh_write(a,b,c)
# define open sh_open
# define lseek sh_seek
# define dup sh_dup
#endif /* !_SH_PRIVATE */
#define SH_SIGSET 4
#define SH_EXITSIG 0400 /* signal exit bit */
#define SH_EXITMASK (SH_EXITSIG-1) /* normal exit status bits */
#define SH_RUNPROG -1022 /* needs to be negative and < 256 */
#define sh_sigcheck() do{if(sh.trapnote&SH_SIGSET)sh_exit(SH_EXITSIG);} while(0)
extern __MANGLE__ Shell_t sh;
extern __MANGLE__ int errno;
#endif /* SH_INTERACTIVE */

View File

@@ -0,0 +1,184 @@
/* $XConsortium: shlex.h /main/3 1995/11/01 16:42:46 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef NOTSYM
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* UNIX shell
* Written by David Korn
* These are the definitions for the lexical analyzer
*/
#include "FEATURE/options"
#include "shnodes.h"
#include "shtable.h"
#include "lexstates.h"
struct shlex_t
{
struct argnod *arg; /* current word */
struct ionod *heredoc; /* pending here document list */
int token; /* current token number */
int lastline; /* last line number */
int lasttok; /* previous token number */
int digits; /* numerical value with word token */
char aliasok; /* on when alias is legal */
char assignok; /* on when name=value is legal */
int inlineno; /* saved value of sh.inlineno */
int firstline; /* saved value of sh.st.firstline */
#ifdef SHOPT_KIA
Sfio_t *kiafile; /* kia output file */
Sfio_t *kiatmp; /* kia reference file */
char *parent; /* parent function */
int entity; /* entity number */
int current; /* current entity number */
off_t kiabegin; /* offset of first entry */
Hashtab_t *file_tree; /* for file names */
#endif /* SHOPT_KIA */
};
/* symbols for parsing */
#define NL '\n'
#define NOTSYM '!'
#define SYMRES 0400 /* reserved word symbols */
#define DOSYM (SYMRES|01)
#define FISYM (SYMRES|02)
#define ELIFSYM (SYMRES|03)
#define ELSESYM (SYMRES|04)
#define INSYM (SYMRES|05)
#define THENSYM (SYMRES|06)
#define DONESYM (SYMRES|07)
#define ESACSYM (SYMRES|010)
#define IFSYM (SYMRES|011)
#define FORSYM (SYMRES|012)
#define WHILESYM (SYMRES|013)
#define UNTILSYM (SYMRES|014)
#define CASESYM (SYMRES|015)
#define FUNCTSYM (SYMRES|016)
#define SELECTSYM (SYMRES|017)
#define TIMESYM (SYMRES|020)
#define SYMREP 01000 /* symbols for doubled characters */
#define BREAKCASESYM (SYMREP|';')
#define ANDFSYM (SYMREP|'&')
#define ORFSYM (SYMREP|'|')
#define IOAPPSYM (SYMREP|'>')
#define IODOCSYM (SYMREP|'<')
#define EXPRSYM (SYMREP|'(')
#define BTESTSYM (SYMREP|'[')
#define ETESTSYM (SYMREP|']')
#define SYMMASK 0170000
#define SYMPIPE 010000 /* trailing '|' */
#define SYMLPAR 020000 /* trailing LPAREN */
#define SYMAMP 040000 /* trailing '&' */
#define SYMGT 0100000 /* trailing '>' */
#define IOMOV0SYM (SYMAMP|'<')
#define IOMOV1SYM (SYMAMP|'>')
#define FALLTHRUSYM (SYMAMP|';')
#define COOPSYM (SYMAMP|'|')
#define IORDWRSYM (SYMGT|'<')
#define IOCLOBSYM (SYMPIPE|'>')
#define IPROCSYM (SYMLPAR|'<')
#define OPROCSYM (SYMLPAR|'>')
#define EOFSYM 04000 /* end-of-file */
#define TESTUNOP 04001
#define TESTBINOP 04002
#define LABLSYM 04003
/* additional parser flag, others in <shell.h> */
#define SH_EMPTY 04
#define SH_NOIO 010
#define SH_ASSIGN 020
#define SH_FUNDEF 040
extern __MANGLE__ struct shlex_t shlex;
extern __MANGLE__ const char e_unexpected[];
extern __MANGLE__ const char e_unmatched[];
extern __MANGLE__ const char e_endoffile[];
extern __MANGLE__ const char e_newline[];
/* odd chars */
#define LBRACE '{'
#define RBRACE '}'
#define LPAREN '('
#define RPAREN ')'
#define LBRACT '['
#define RBRACT ']'
extern __MANGLE__ int sh_lex __PROTO__((void));
extern __MANGLE__ void sh_lexinit __PROTO__((int));
extern __MANGLE__ void sh_lexskip __PROTO__((int,int,int));
extern __MANGLE__ void sh_syntax __PROTO__((void));
#endif /* !NOTSYM */

View File

@@ -0,0 +1,258 @@
/* $XConsortium: shnodes.h /main/3 1995/11/01 16:43:01 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef _SHNODES_H
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define _SHNODES_H 1
/*
* UNIX shell
* Written by David Korn
*
*/
#include <ast.h>
#include "argnod.h"
/* command tree for tretyp */
#define FINT (02<<COMBITS) /* non-interruptable */
#define FAMP (04<<COMBITS) /* background */
#define FPIN (010<<COMBITS) /* input is a pipe */
#define FPOU (040<<COMBITS) /* output is a pipe */
#define FPCL (0100<<COMBITS) /* close the pipe */
#define FCOOP (0200<<COMBITS) /* cooperating process */
#define FPOSIX (02<<COMBITS) /* posix semantics function */
#define TNEGATE (01<<COMBITS) /* ! inside [[...]] */
#define TBINARY (02<<COMBITS) /* binary operator in [[...]] */
#define TUNARY (04<<COMBITS) /* unary operator in [[...]] */
#define TTEST (010<<COMBITS)
#define TPAREN (TBINARY|TUNARY)
#define TSHIFT (COMBITS+4)
#define TCOM 0
#define TPAR 1
#define TFIL 2
#define TLST 3
#define TIF 4
#define TWH 5
#define TUN (TWH|COMSCAN)
#define TTST 6
#define TSW 7
#define TAND 8
#define TORF 9
#define TFORK 10
#define TFOR 11
#define TSELECT (TFOR|COMSCAN)
#define TARITH 12
#define TTIME 13
#define TSETIO 14
#define TFUN 15
/* this node is a proforma for those that follow */
struct trenod
{
int tretyp;
struct ionod *treio;
};
struct forknod
{
int forktyp;
struct ionod *forkio;
union anynode *forktre;
int forkline;
};
struct ifnod
{
int iftyp;
union anynode *iftre;
union anynode *thtre;
union anynode *eltre;
};
struct whnod
{
int whtyp;
union anynode *whtre;
union anynode *dotre;
struct arithnod *whinc;
};
struct fornod
{
int fortyp;
union anynode *fortre;
char *fornam;
struct comnod *forlst;
};
struct swnod
{
int swtyp;
struct argnod *swarg;
struct regnod *swlst;
};
struct regnod
{
struct argnod *regptr;
union anynode *regcom;
struct regnod *regnxt;
char regflag;
};
struct parnod
{
int partyp;
union anynode *partre;
};
struct lstnod
{
int lsttyp;
union anynode *lstlef;
union anynode *lstrit;
};
/* tst is same as lst, but with extra field for line number */
struct tstnod
{
struct lstnod tstlst;
int tstline;
};
struct functnod
{
int functtyp;
int functline;
union anynode *functtre;
char *functnam;
off_t functloc;
struct slnod *functstak;
struct comnod *functargs;
};
struct arithnod
{
int artyp;
int arline;
struct argnod *arexpr;
};
/* types of ionodes stored in iofile */
#define IOUFD 0x3f /* file descriptor number mask */
#define IOPUT 0x40 /* > redirection operator */
#define IOAPP 0x80 /* >> redirection operator */
#define IODOC 0x100 /* << redirection operator */
#define IOMOV 0x200 /* <& or >& operators */
#define IOCLOB 0x400 /* noclobber bit */
#define IORDW 0x800 /* <> redirection operator */
#define IORAW 0x1000 /* no expansion needed for filename */
#define IOSTRG 0x2000 /* here-document stored as incore string */
#define IOSTRIP 0x4000 /* strip leading tabs for here-document */
#define IOQUOTE 0x8000 /* here-document delimiter was quoted */
union anynode
{
struct argnod arg;
struct ionod io;
struct whnod wh;
struct swnod sw;
struct ifnod if_;
struct dolnod dol;
struct comnod com;
struct trenod tre;
struct forknod fork;
struct fornod for_;
struct regnod reg;
struct parnod par;
struct lstnod lst;
struct tstnod tst;
struct functnod funct;
struct arithnod ar;
};
extern __MANGLE__ void sh_freeup __PROTO__((void));
extern __MANGLE__ void sh_funstaks __PROTO__((struct slnod*,int));
extern __MANGLE__ int sh_exec __PROTO__((const union anynode*,int));
extern __MANGLE__ union anynode *sh_dolparen __PROTO__((void));
#ifdef SHOPT_KIA
extern __MANGLE__ int kiaclose __PROTO__((void));
#endif /* SHOPT_KIA */
#endif /* _SHNODES_H */

View File

@@ -0,0 +1,120 @@
/* $XConsortium: shtable.h /main/5 1996/09/06 17:03:55 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef _SHTABLE_H
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* David Korn
* AT&T Bell Laboratories
*
* Interface definitions read-only data tables for shell
*
*/
#define _SHTABLE_H 1
typedef struct shtable1
{
const char *sh_name;
unsigned sh_number;
} Shtable_t;
struct shtable2
{
const char *sh_name;
unsigned sh_number;
const char *sh_value;
};
struct shtable3
{
const char *sh_name;
unsigned sh_number;
int (*sh_value) __PROTO__((int, char*[], __V_*));
};
#define sh_lookup(name,value) sh_locate(name,(Shtable_t*)(value),sizeof(*(value)))
extern __MANGLE__ const Shtable_t shtab_testops[];
extern __MANGLE__ const Shtable_t shtab_options[];
extern __MANGLE__ const Shtable_t shtab_attributes[];
extern __MANGLE__ const Shtable_t shtab_limits[];
extern __MANGLE__ const struct shtable2 shtab_variables[];
extern __MANGLE__ const struct shtable2 shtab_aliases[];
extern __MANGLE__ const struct shtable2 *shtab_signals;
extern __MANGLE__ const struct shtable3 shtab_builtins[];
extern __MANGLE__ const Shtable_t shtab_reserved[];
extern __MANGLE__ const Shtable_t shtab_config[];
extern __MANGLE__ int sh_locate __PROTO__((const char*, const Shtable_t*, int));
extern __MANGLE__ void init_shtab_signals __PROTO__ ((void));
#endif /* SH_TABLE_H */

View File

@@ -0,0 +1,170 @@
/* $XConsortium: streval.h /main/3 1995/11/01 16:43:32 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SEQPOINT
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* G. S. Fowler
* D. G. Korn
* AT&T Bell Laboratories
*
* long integer arithmetic expression evaluator
*/
/* The following only is needed for const */
#include <ast.h>
#include <math.h>
struct lval
{
char *value;
double (*fun) __PROTO__((double));
short flag;
char isfloat;
};
struct mathtab
{
char fname[4];
double (*fnptr) __PROTO__((double));
};
#define MAXPREC 15 /* maximum precision level */
#define SEQPOINT 0200 /* sequence point */
#define NOASSIGN 0100 /* assignment legal with this operator */
#define RASSOC 040 /* right associative */
#define NOFLOAT 020 /* illegal with floating point */
#define PRECMASK 017 /* precision bit mask */
#define A_EOF 1
#define A_NEQ 2
#define A_NOT 3
#define A_MOD 4
#define A_ANDAND 5
#define A_AND 6
#define A_LPAR 7
#define A_RPAR 8
#define A_TIMES 9
#define A_PLUSPLUS 10
#define A_PLUS 11
#define A_COMMA 12
#define A_MINUSMINUS 13
#define A_MINUS 14
#define A_DIV 15
#define A_LSHIFT 16
#define A_LE 17
#define A_LT 18
#define A_EQ 19
#define A_ASSIGN 20
#define A_COLON 21
#define A_RSHIFT 22
#define A_GE 23
#define A_GT 24
#define A_QCOLON 25
#define A_QUEST 26
#define A_XOR 27
#define A_OROR 28
#define A_OR 29
#define A_REG 30
#define A_DIG 31
#define A_DOT 32
/* define error messages */
extern __MANGLE__ const unsigned char strval_precedence[33];
extern __MANGLE__ const char strval_states[64];
extern __MANGLE__ const char e_moretokens[];
extern __MANGLE__ const char e_paren[];
extern __MANGLE__ const char e_badnum[];
extern __MANGLE__ const char e_badcolon[];
extern __MANGLE__ const char e_recursive[];
extern __MANGLE__ const char e_divzero[];
extern __MANGLE__ const char e_synbad[];
extern __MANGLE__ const char e_notlvalue[];
extern __MANGLE__ const char e_function[];
extern __MANGLE__ const char e_questcolon[];
extern __MANGLE__ const char e_incompatible[];
extern __MANGLE__ const char e_domain[];
extern __MANGLE__ const char e_overflow[];
extern __MANGLE__ const char e_singularity[];
extern __MANGLE__ const struct mathtab shtab_math[];
/* function code for the convert function */
#define LOOKUP 0
#define ASSIGN 1
#define VALUE 2
#define ERRMSG 3
extern __MANGLE__ double strval __PROTO__((const char*,char**,double(*)(const char**,struct lval*,int,double)));
#endif /* !SEQPOINT */

View File

@@ -0,0 +1,259 @@
/* $XConsortium: terminal.h /main/3 1995/11/01 16:43:45 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef _terminal_
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define _terminal_ 1
#include "FEATURE/ttys"
/*
* terminal interface
* complicated by the fact that there are so many variations
* This will use POSIX <termios.h> interface where available
*/
#ifdef _hdr_termios
# define tcgetattr _SYS_tcgetattr
# define tcsetattr _SYS_tcsetattr
# define tcgetpgrp _SYS_tcgetpgrp
# define tcsetpgrp _SYS_tcsetpgrp
# define cfgetospeed _SYS_cfgetospeed
# include <termios.h>
# if __sgi__ || sgi /* special hack to eliminate ^M problem */
# ifndef ECHOCTL
# define ECHOCTL ECHOE
# endif /* ECHOCTL */
# ifndef CNSUSP
# define CNSUSP CNSWTCH
# endif /* CNSUSP */
# endif /* sgi */
# ifdef _NEXT_SOURCE
# define _lib_tcgetattr 1
# define _lib_tcgetpgrp 1
# endif /* _NEXT_SOURCE */
#else
# if defined(_sys_termios) && defined(_lib_tcgetattr)
# define tcgetattr _SYS_tcgetattr
# define tcsetattr _SYS_tcsetattr
# define tcgetpgrp _SYS_tcgetpgrp
# define tcsetpgrp _SYS_tcsetpgrp
# define cfgetospeed _SYS_cfgetospeed
# include <sys/termios.h>
# define _hdr_termios
# else
# undef _sys_termios
# endif /* _sys_termios */
#endif /* _hdr_termios */
#ifdef _hdr_termios
# undef _hdr_sgtty
# undef tcgetattr
# undef tcsetattr
# undef tcgetpgrp
# undef tcsetpgrp
# undef cfgetospeed
# ifndef TCSANOW
# define TCSANOW TCSETS
# define TCSADRAIN TCSETSW
# define TCSAFLUSH TCSETSF
# endif /* TCSANOW */
/* The following corrects bugs in some implementations */
# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
# define TCSAFLUSH TCSADFLUSH
# endif /* TCSADFLUSH */
# ifndef _lib_tcgetattr
# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
# else
extern __MANGLE__ int tcgetattr __PROTO__((int, struct termios*));
extern __MANGLE__ int tcsetattr __PROTO__((int, int, const struct termios*));
extern __MANGLE__ int cfgetospeed __PROTO__((const struct termios*));
# endif /* _lib_tcgetattr */
# undef TIOCGETC
# ifdef SHOPT_OLDTERMIO /* use both termios and termio */
# ifdef _hdr_termio
# include <termio.h>
# else
# ifdef _sys_termio
# include <sys/termio.h>
# define _hdr_termio 1
# else
# undef SHOPT_OLDTERMIO
# endif /* _sys_termio */
# endif /* _hdr_termio */
# endif /* SHOPT_OLDTERMIO */
#else
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
# undef SHOPT_OLDTERMIO
# ifdef _hdr_termio
# include <termio.h>
# else
# ifdef _sys_termio
# include <sys/termio.h>
# define _hdr_termio 1
# endif /* _sys_termio */
# endif /* _hdr_termio */
# ifdef _hdr_termio
# define termios termio
# undef TIOCGETC
# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# ifdef _sys_bsdtty
# include <sys/bsdtty.h>
# endif /* _sys_bsdtty */
# else
# ifdef _hdr_sgtty
# include <sgtty.h>
# ifndef LPENDIN
# ifdef _sys_nttyio
# include <sys/nttyio.h>
# endif /* _sys_nttyio */
# endif /* LPENDIN */
# define termios sgttyb
# ifdef TIOCSETN
# undef TCSETAW
# endif /* TIOCSETN */
# ifdef TIOCGETP
# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# else
# define tcgetattr(fd,tty) gtty(fd, tty)
# define tcsetattr(fd,action,tty) stty(fd, tty)
# endif /* TIOCGETP */
# endif /* _hdr_sgtty */
# endif /* hdr_termio */
# ifndef TCSANOW
# ifdef TCSETAW
# define TCSANOW TCSETA
# ifdef u370
/* delays are too long, don't wait for output to drain */
# define TCSADRAIN TCSETA
# else
# define TCSADRAIN TCSETAW
# endif /* u370 */
# define TCSAFLUSH TCSETAF
# else
# ifdef TIOCSETN
# define TCSANOW TIOCSETN
# define TCSADRAIN TIOCSETN
# define TCSAFLUSH TIOCSETP
# endif /* TIOCSETN */
# endif /* TCSETAW */
# endif /* TCSANOW */
#endif /* _hdr_termios */
/* set ECHOCTL if driver can echo control charaters as ^c */
#ifdef LCTLECH
# ifndef ECHOCTL
# define ECHOCTL LCTLECH
# endif /* !ECHOCTL */
#endif /* LCTLECH */
#ifdef LNEW_CTLECH
# ifndef ECHOCTL
# define ECHOCTL LNEW_CTLECH
# endif /* !ECHOCTL */
#endif /* LNEW_CTLECH */
#ifdef LNEW_PENDIN
# ifndef PENDIN
# define PENDIN LNEW_PENDIN
# endif /* !PENDIN */
#endif /* LNEW_PENDIN */
#ifndef ECHOCTL
# ifndef VEOL
# define RAWONLY 1
# endif /* !VEOL */
#endif /* !ECHOCTL */
#ifdef _sys_filio
# ifndef FIONREAD
# include <sys/filio.h>
# endif /* FIONREAD */
#endif /* _sys_filio */
/* set FIORDCHK if you can check for characters in input queue */
#ifdef FIONREAD
# ifndef FIORDCHK
# define FIORDCHK FIONREAD
# endif /* !FIORDCHK */
#endif /* FIONREAD */
extern __MANGLE__ int tty_alt __PROTO__((int));
extern __MANGLE__ void tty_cooked __PROTO__((int));
extern __MANGLE__ int tty_get __PROTO__((int,struct termios*));
extern __MANGLE__ int tty_raw __PROTO__((int,int));
extern __MANGLE__ int tty_check __PROTO__((int));
extern __MANGLE__ int tty_set __PROTO__((int, int, struct termios*));
#endif /* _terminal_ */

View File

@@ -0,0 +1,121 @@
/* $XConsortium: test.h /main/3 1995/11/01 16:44:00 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef TEST_ARITH
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
/*
* UNIX shell
* David Korn
* AT&T Bell Laboratories
*
*/
#include "shtable.h"
/*
* These are the valid test operators
*/
#define TEST_ARITH 040 /* arithmetic operators */
#define TEST_BINOP 0200 /* binary operator */
#define TEST_PATTERN 0100 /* turn off bit for pattern compares */
#define TEST_NE (TEST_ARITH|9)
#define TEST_EQ (TEST_ARITH|4)
#define TEST_GE (TEST_ARITH|5)
#define TEST_GT (TEST_ARITH|6)
#define TEST_LE (TEST_ARITH|7)
#define TEST_LT (TEST_ARITH|8)
#define TEST_OR (TEST_BINOP|1)
#define TEST_AND (TEST_BINOP|2)
#define TEST_SNE (TEST_PATTERN|1)
#define TEST_SEQ (TEST_PATTERN|14)
#define TEST_PNE 1
#define TEST_PEQ 14
#define TEST_EF 3
#define TEST_NT 10
#define TEST_OT 12
#define TEST_SLT 15
#define TEST_SGT 16
#define TEST_END 8
extern __MANGLE__ int test_unop __PROTO__((int, const char*));
extern __MANGLE__ int test_inode __PROTO__((const char*, const char*));
extern __MANGLE__ int test_binop __PROTO__((int, const char*, const char*));
extern __MANGLE__ const char test_opchars[];
extern __MANGLE__ const char e_argument[];
extern __MANGLE__ const char e_missing[];
extern __MANGLE__ const char e_badop[];
extern __MANGLE__ const char e_tstbegin[];
extern __MANGLE__ const char e_tstend[];
#endif /* TEST_ARITH */

View File

@@ -0,0 +1,38 @@
/* $XConsortium: timeout.h /main/3 1995/11/01 16:44:14 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/*
* UNIX shell
*
* S. R. Bourne
* AT&T Bell Laboratories
*
*/
#define TGRACE 60 /* grace period before termination */
/* The time_warn message contains this number */
extern long sh_timeout;
extern const char e_timeout[];
extern const char e_timewarn[];

View File

@@ -0,0 +1,152 @@
/* $XConsortium: ulimit.h /main/3 1995/11/01 16:44:27 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef _ULIMIT_H
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#define _ULIMIT_H 1
/*
* This is for the ulimit built-in command
*/
#include "shtable.h"
#include "FEATURE/rlimits"
#if defined(_sys_resource) && defined(_lib_getrlimit)
# include "FEATURE/time"
# include <sys/resource.h>
# if !defined(RLIMIT_FSIZE) && defined(_sys_vlimit)
/* This handles hp/ux problem */
# include <sys/vlimit.h>
# define RLIMIT_FSIZE (LIM_FSIZE-1)
# define RLIMIT_DATA (LIM_DATA-1)
# define RLIMIT_STACK (LIM_STACK-1)
# define RLIMIT_CORE (LIM_CORE-1)
# define RLIMIT_CPU (LIM_CPU-1)
# ifdef LIM_MAXRSS
# define RLIMIT_RSS (LIM_MAXRSS-1)
# endif /* LIM_MAXRSS */
# endif
# undef _lib_ulimit
#else
# ifdef _sys_vlimit
# include <sys/vlimit.h>
# undef _lib_ulimit
# define RLIMIT_FSIZE LIM_FSIZE
# define RLIMIT_DATA LIM_DATA
# define RLIMIT_STACK LIM_STACK
# define RLIMIT_CORE LIM_CORE
# define RLIMIT_CPU LIM_CPU
# ifdef LIM_MAXRSS
# define RLIMIT_RSS LIM_MAXRSS
# endif /* LIM_MAXRSS */
# else
# ifdef _lib_ulimit
# define vlimit ulimit
# endif /* _lib_ulimit */
# endif /* _lib_vlimit */
#endif
#ifdef RLIM_INFINITY
# define INFINITY RLIM_INFINITY
#else
# ifndef INFINITY
# define INFINITY -1L
# endif /* INFINITY */
#endif /* RLIM_INFINITY */
#if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
# ifndef RLIMIT_CPU
# define RLIMIT_CPU 0
# endif /* !RLIMIT_CPU */
# ifndef RLIMIT_DATA
# define RLIMIT_DATA 0
# endif /* !RLIMIT_DATA */
# ifndef RLIMIT_RSS
# define RLIMIT_RSS 0
# endif /* !RLIMIT_RSS */
# ifndef RLIMIT_STACK
# define RLIMIT_STACK 0
# endif /* !RLIMIT_STACK */
# ifndef RLIMIT_CORE
# define RLIMIT_CORE 0
# endif /* !RLIMIT_CORE */
# ifndef RLIMIT_VMEM
# define RLIMIT_VMEM 0
# endif /* !RLIMIT_VMEM */
# ifndef RLIMIT_NOFILE
# define RLIMIT_NOFILE 0
# endif /* !RLIMIT_NOFILE */
#else
# define _no_ulimit
#endif
extern __MANGLE__ const char e_unlimited[];
#endif /* _ULIMIT_H */

View File

@@ -0,0 +1,157 @@
/* $XConsortium: variables.h /main/3 1995/11/01 16:44:43 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#ifndef SH_VALNOD
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <option.h>
#include "FEATURE/options"
#include "FEATURE/dynamic"
/* The following defines are coordinated with data in data/variables.c */
#define PATHNOD (sh.bltin_nodes)
#define PS1NOD (sh.bltin_nodes+1)
#define PS2NOD (sh.bltin_nodes+2)
#define IFSNOD (sh.bltin_nodes+3)
#define PWDNOD (sh.bltin_nodes+4)
#define HOME (sh.bltin_nodes+5)
#define MAILNOD (sh.bltin_nodes+6)
#define REPLYNOD (sh.bltin_nodes+7)
#define SHELLNOD (sh.bltin_nodes+8)
#define EDITNOD (sh.bltin_nodes+9)
#define MCHKNOD (sh.bltin_nodes+10)
#define RANDNOD (sh.bltin_nodes+11)
#define ENVNOD (sh.bltin_nodes+12)
#define HISTFILE (sh.bltin_nodes+13)
#define HISTSIZE (sh.bltin_nodes+14)
#define HISTEDIT (sh.bltin_nodes+15)
#define HISTCUR (sh.bltin_nodes+16)
#define FCEDNOD (sh.bltin_nodes+17)
#define CDPNOD (sh.bltin_nodes+18)
#define MAILPNOD (sh.bltin_nodes+19)
#define PS3NOD (sh.bltin_nodes+20)
#define OLDPWDNOD (sh.bltin_nodes+21)
#define VISINOD (sh.bltin_nodes+22)
#define COLUMNS (sh.bltin_nodes+23)
#define LINES (sh.bltin_nodes+24)
#define PPIDNOD (sh.bltin_nodes+25)
#define L_ARGNOD (sh.bltin_nodes+26)
#define TMOUTNOD (sh.bltin_nodes+27)
#define SECONDS (sh.bltin_nodes+28)
#define LINENO (sh.bltin_nodes+29)
#define OPTARGNOD (sh.bltin_nodes+30)
#define OPTINDNOD (sh.bltin_nodes+31)
#define PS4NOD (sh.bltin_nodes+32)
#define FPATHNOD (sh.bltin_nodes+33)
#define LANGNOD (sh.bltin_nodes+34)
#define LCALLNOD (sh.bltin_nodes+35)
#define LCCOLLNOD (sh.bltin_nodes+36)
#define LCTYPENOD (sh.bltin_nodes+37)
#define LCMSGNOD (sh.bltin_nodes+38)
#define LCNUMNOD (sh.bltin_nodes+39)
#define FIGNORENOD (sh.bltin_nodes+40)
#define DOTSHNOD (sh.bltin_nodes+41)
#define ED_CHRNOD (sh.bltin_nodes+42)
#define ED_COLNOD (sh.bltin_nodes+43)
#define ED_TXTNOD (sh.bltin_nodes+44)
#define ED_MODENOD (sh.bltin_nodes+45)
#define SH_NAMENOD (sh.bltin_nodes+46)
#define SH_SUBSCRNOD (sh.bltin_nodes+47)
#define SH_VALNOD (sh.bltin_nodes+48)
#define SH_VERSIONNOD (sh.bltin_nodes+49)
#define SH_DOLLARNOD (sh.bltin_nodes+50)
#ifdef SHOPT_FS_3D
# define VPATHNOD (sh.bltin_nodes+51)
# define NFS_3D 1
#else
# define NFS_3D 0
#endif /* SHOPT_FS_3D */
#ifdef SHOPT_VPIX
# define DOSPATHNOD (sh.bltin_nodes+51+NFS_3D)
# define VPIXNOD (sh.bltin_nodes+52+NFS_3D)
# define NVPIX (NFS_3D+2)
#else
# define NVPIX NFS_3D
#endif /* SHOPT_VPIX */
#ifdef SHOPT_MULTIBYTE
# define CSWIDTHNOD (sh.bltin_nodes+51+NVPIX)
# define NMULTI NVPIX+1
#else
# define NMULTI NVPIX
#endif /* SHOPT_MULTIBYTE */
#ifdef apollo
# define SYSTYPENOD (sh.bltin_nodes+51+NMULTI)
#endif /* apollo */
#endif /* SH_VALNOD */

View File

@@ -0,0 +1,933 @@
# $XConsortium: ksh.mk /main/3 1996/10/30 14:43:12 drk $
# # oldmake makefile generated by mamold # #
# oldmake ... null='' sharp='$(null)#' newline='$(null)
# '
newline=;
CC=cc
LEX=lex
LD=ld
MAKE=nmake
YACC=yacc
PACKAGE_ast_INCLUDE=${PACKAGE_ast}/include
CCFLAGS=-O
mam_libcmd=`$${mam_cc_L+cat} $${mam_cc_L-sed} $${mam_cc_L-s,-lcmd,${INSTALLROOT}/lib/libcmd.a,} \
${PACKAGE_ast_LIB}/lib/cmd`
SHELL=/bin/sh
YACCFLAGS=-d
mam_libast=$${mam_cc_L+-last}$${mam_cc_L-${PACKAGE_ast_LIB}/libast.a}
LPR=lpr
mam_libdl=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -ldl \
>/dev/null 2>&1 && echo ' -ldl'; rm -f x.$${!-$$$$}.[cox])`
mam_libjobs=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -ljobs \
>/dev/null 2>&1 && echo ' -ljobs'; rm -f x.$${!-$$$$}.[cox])`
COTEMP=$$$$
mam_libintl=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -lintl \
>/dev/null 2>&1 && echo ' -lintl'; rm -f x.$${!-$$$$}.[cox])`
mam_libi=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -li \
>/dev/null 2>&1 && echo ' -li'; rm -f x.$${!-$$$$}.[cox])`
PACKAGE_ast=${INSTALLROOT}
CPP=${CC} -E
PR=pr
mam_libm=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -lm \
>/dev/null 2>&1 && echo ' -lm'; rm -f x.$${!-$$$$}.[cox])`
INSTALLROOT=../../..
HOSTCC=${CC}
ARFLAGS=cr
F77=f77
PACKAGE_ast_LIB=${PACKAGE_ast}/lib
AR=ar
AS=as
TAR=tar
mam_libdld=`(set -; cd /tmp; echo 'main(){return(0);}' > x.$${!-$$$$}.c; \
${CC} ${CCFLAGS} -o x.$${!-$$$$}.x x.$${!-$$$$}.c -ldld \
>/dev/null 2>&1 && echo ' -ldld'; rm -f x.$${!-$$$$}.[cox])`
CPIO=cpio
install : all ${INSTALLROOT}/bin ${INSTALLROOT}/bin/ksh \
${INSTALLROOT}/man/man1 ${INSTALLROOT}/man/man1/sh.1 \
${INSTALLROOT}/lib ${INSTALLROOT}/lib/libshell.a \
${INSTALLROOT}/man/man3 ${INSTALLROOT}/man/man3/nval.3 \
${INSTALLROOT}/include/ast \
${INSTALLROOT}/include/ast/nval.h \
${INSTALLROOT}/include/ast/shell.h \
${INSTALLROOT}/bin/suid_exec ${INSTALLROOT}/bin/shcomp
all : ksh shcomp ksh.msg sh/suid_exec.c \
${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sig.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h FEATURE/externs \
${PACKAGE_ast_INCLUDE}/ast/ast.h shell libshell.a \
suid_exec
ksh : main.o libshell.a
${CC} ${CCFLAGS} ${LDFLAGS} $${mam_cc_L+-L.} $${mam_cc_L+-L${PACKAGE_ast_LIB}} \
-o ksh main.o libshell.a ${mam_libcmd} ${mam_cc_static} ${mam_libast} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libm} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} ${mam_cc_static} \
${mam_libi} ${mam_cc_dynamic} ${mam_libdl} ${mam_libdld} \
${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} ${mam_libast}
main.o : sh/main.c FEATURE/externs FEATURE/execargs FEATURE/pstat \
FEATURE/time include/timeout.h include/history.h \
include/shnodes.h include/jobs.h FEATURE/ttys \
FEATURE/options include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h include/path.h \
FEATURE/acct include/variables.h FEATURE/dynamic \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
${PACKAGE_ast_INCLUDE}/ast/ls.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -DKSHELL -c sh/main.c
FEATURE/externs : features/externs
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/externs
FEATURE/execargs :
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : def execargs
FEATURE/pstat :
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : def pstat
FEATURE/time : features/time
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/time
FEATURE/ttys : features/ttys
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/ttys
FEATURE/options : features/options.sh
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/options.sh OPTIONS
FEATURE/acct :
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : def acct
FEATURE/dynamic : features/dynamic
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/dynamic
FEATURE/sigfeatures : features/sigfeatures
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/sigfeatures
FEATURE/setjmp : features/setjmp
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/setjmp
libshell.a : alarm.o cd_pwd.o cflow.o getopts.o hist.o misc.o print.o \
read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o \
whence.o arith.o args.o array.o completion.o dlopen.o \
defs.o edit.o expand.o fault.o fcin.o history.o init.o \
io.o jobs.o lex.o macro.o name.o parse.o path.o string.o \
streval.o subshell.o tdump.o timers.o trestore.o \
userinit.o xec.o limits.o msg.o strdata.o testops.o \
keywords.o options.o signals.o aliases.o builtins.o \
variables.o lexstates.o emacs.o vi.o
${AR} cr libshell.a alarm.o cd_pwd.o cflow.o getopts.o hist.o misc.o \
print.o read.o sleep.o trap.o test.o typeset.o ulimit.o umask.o \
whence.o arith.o args.o array.o completion.o dlopen.o defs.o \
edit.o expand.o fault.o fcin.o history.o init.o io.o jobs.o \
lex.o$(newline) \
${AR} cr libshell.a macro.o name.o parse.o path.o string.o streval.o \
subshell.o tdump.o timers.o trestore.o userinit.o xec.o limits.o \
msg.o strdata.o testops.o keywords.o options.o signals.o \
aliases.o builtins.o variables.o lexstates.o emacs.o vi.o$(newline) \
(ranlib libshell.a) >/dev/null 2>&1 || true
alarm.o : bltins/alarm.c FEATURE/time include/builtins.h \
FEATURE/options ${PACKAGE_ast_INCLUDE}/ast/stak.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/alarm.c
cd_pwd.o : bltins/cd_pwd.c ${PACKAGE_ast_INCLUDE}/ast/ls.h \
include/builtins.h FEATURE/dynamic FEATURE/options \
include/name.h include/path.h FEATURE/acct \
include/variables.h ${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/stak.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/cd_pwd.c
cflow.o : bltins/cflow.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/shnodes.h \
${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/cflow.c
getopts.o : bltins/getopts.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/nval.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/variables.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/getopts.c
hist.o : bltins/hist.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/history.h include/name.h \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/variables.h \
${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h \
${PACKAGE_ast_INCLUDE}/ast/stak.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c bltins/hist.c
misc.o : bltins/misc.c include/jobs.h FEATURE/ttys FEATURE/options \
include/builtins.h FEATURE/dynamic include/history.h \
include/name.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/shnodes.h include/variables.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c bltins/misc.c
print.o : bltins/print.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/history.h include/name.h \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/stak.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c bltins/print.c
read.o : bltins/read.c include/national.h include/terminal.h \
include/history.h include/builtins.h FEATURE/dynamic \
FEATURE/options include/name.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/lexstates.h \
include/variables.h include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp ${PACKAGE_ast_INCLUDE}/ast/error.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -DKSHELL -c bltins/read.c
sleep.o : bltins/sleep.c FEATURE/poll FEATURE/time include/builtins.h \
FEATURE/dynamic FEATURE/options \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/sleep.c
FEATURE/poll : features/poll
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/poll
trap.o : bltins/trap.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/jobs.h FEATURE/ttys \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/trap.c
test.o : bltins/test.c FEATURE/externs include/builtins.h \
FEATURE/dynamic FEATURE/options include/test.h \
include/terminal.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c bltins/test.c
typeset.o : bltins/typeset.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/history.h include/name.h \
include/path.h FEATURE/acct \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
include/variables.h \
FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/typeset.c
ulimit.o : bltins/ulimit.c include/ulimit.h FEATURE/rlimits \
include/builtins.h FEATURE/dynamic FEATURE/options \
include/shell.h ${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/ulimit.c
FEATURE/rlimits : features/rlimits
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/rlimits
umask.o : bltins/umask.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/shell.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h \
${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/umask.c
whence.o : bltins/whence.c include/builtins.h FEATURE/dynamic \
FEATURE/options include/shlex.h include/path.h \
FEATURE/acct include/name.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c bltins/whence.c
arith.o : sh/arith.c FEATURE/locale include/streval.h include/name.h \
include/lexstates.h include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp include/history.h FEATURE/options
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -c sh/arith.c
FEATURE/locale : features/locale
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/locale
args.o : sh/args.c include/terminal.h include/builtins.h \
FEATURE/dynamic FEATURE/options include/path.h \
FEATURE/acct include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -DSHOPT_ESH -c sh/args.c
array.o : sh/array.c include/name.h ${PACKAGE_ast_INCLUDE}/ast/stak.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h FEATURE/options
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -c sh/array.c
completion.o : edit/completion.c include/history.h include/edit.h \
FEATURE/setjmp FEATURE/options include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/lexstates.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DKSHELL -DSHOPT_VSH -DSHOPT_SUID_EXEC -c edit/completion.c
dlopen.o : sh/dlopen.c FEATURE/dynamic include/nval.h \
${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
sh/dlopen.c
defs.o : sh/defs.c include/timeout.h include/edit.h FEATURE/setjmp \
FEATURE/options include/shlex.h include/jobs.h \
FEATURE/ttys include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DKSHELL -DSHOPT_SUID_EXEC -c sh/defs.c
edit.o : edit/edit.c include/edit.h FEATURE/setjmp FEATURE/options \
include/history.h include/terminal.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h FEATURE/time \
include/path.h FEATURE/acct
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DKSHELL -DSHOPT_SUID_EXEC -c edit/edit.c
expand.o : sh/expand.c include/path.h FEATURE/acct FEATURE/options \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/ast_dir.h \
${PACKAGE_ast_INCLUDE}/ast/stak.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_SUID_EXEC \
-DSHOPT_VSH -DSHOPT_ESH -DKSHELL -c sh/expand.c
fault.o : sh/fault.c include/path.h FEATURE/acct FEATURE/options \
include/jobs.h FEATURE/ttys include/shnodes.h \
include/history.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/fcin.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -DKSHELL -c sh/fault.c
fcin.o : sh/fcin.c include/fcin.h ${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
sh/fcin.c
history.o : edit/history.c include/national.h include/history.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h \
${PACKAGE_ast_INCLUDE}/ast/error.h FEATURE/time \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_ESH -DKSHELL -DSHOPT_SUID_EXEC -c edit/history.c
init.o : sh/init.c include/national.h FEATURE/locale \
include/lexstates.h FEATURE/dynamic FEATURE/time \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/jobs.h \
FEATURE/ttys FEATURE/options include/name.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/path.h FEATURE/acct include/variables.h \
${PACKAGE_ast_INCLUDE}/ast/stak.h include/defs.h \
include/shell.h include/argnod.h include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_ESH -DSHOPT_VSH -DSHOPT_SUID_EXEC -c sh/init.c
io.o : sh/io.c FEATURE/poll FEATURE/dynamic FEATURE/externs \
include/timeout.h include/edit.h FEATURE/setjmp \
FEATURE/options include/history.h include/shnodes.h \
include/jobs.h FEATURE/ttys include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/variables.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h include/fcin.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_ESH -DKSHELL -DSHOPT_SUID_EXEC -c sh/io.c
jobs.o : sh/jobs.c include/history.h include/jobs.h FEATURE/ttys \
FEATURE/options include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/wait.h include/defs.h \
include/shell.h include/argnod.h include/fault.h \
FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_ESH -DSHOPT_SUID_EXEC -DKSHELL -c sh/jobs.c
lex.o : sh/lex.c include/lexstates.h include/test.h include/shlex.h \
FEATURE/options include/argnod.h include/nval.h \
include/fcin.h ${PACKAGE_ast_INCLUDE}/ast/stak.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -DKSHELL -c sh/lex.c
macro.o : sh/macro.c include/national.h include/path.h FEATURE/acct \
FEATURE/options include/shnodes.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/shlex.h \
include/variables.h FEATURE/dynamic include/name.h \
include/fcin.h include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_SUID_EXEC -DSHOPT_VSH -DSHOPT_ESH -c sh/macro.c
name.o : sh/name.c include/national.h FEATURE/locale include/timeout.h \
include/lexstates.h include/path.h FEATURE/acct \
FEATURE/options include/variables.h FEATURE/dynamic \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c sh/name.c
parse.o : sh/parse.c include/test.h include/builtins.h FEATURE/dynamic \
FEATURE/options include/history.h include/shlex.h \
${PACKAGE_ast_INCLUDE}/ast/error.h include/fcin.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c sh/parse.c
path.o : sh/path.c FEATURE/time FEATURE/externs include/test.h \
include/history.h include/jobs.h FEATURE/ttys \
FEATURE/options include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/variables.h FEATURE/dynamic \
${PACKAGE_ast_INCLUDE}/ast/ls.h include/fcin.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_SUID_EXEC \
-DSHOPT_ESH -DSHOPT_VSH -DKSHELL -c sh/path.c
string.o : sh/string.c include/national.h include/lexstates.h \
include/shtable.h ${PACKAGE_ast_INCLUDE}/ast/stak.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h FEATURE/options \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -c sh/string.c
streval.o : sh/streval.c FEATURE/externs \
${PACKAGE_ast_INCLUDE}/ast/error.h include/streval.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
sh/streval.c
subshell.o : sh/subshell.c include/path.h FEATURE/acct FEATURE/options \
include/variables.h FEATURE/dynamic include/jobs.h \
FEATURE/ttys include/shlex.h include/shnodes.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h include/defs.h \
include/shell.h include/argnod.h include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_SUID_EXEC \
-DSHOPT_VSH -DSHOPT_ESH -DKSHELL -c sh/subshell.c
tdump.o : sh/tdump.c include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct FEATURE/options include/shnodes.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_SUID_EXEC -DSHOPT_VSH -DSHOPT_ESH -c sh/tdump.c
timers.o : sh/timers.c FEATURE/time FEATURE/sigfeatures include/fault.h \
FEATURE/setjmp ${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sig.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
sh/timers.c
trestore.o : sh/trestore.c include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct FEATURE/options include/shnodes.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_SUID_EXEC -DSHOPT_VSH -DSHOPT_ESH -c sh/trestore.c
userinit.o : sh/userinit.c include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp include/history.h FEATURE/options
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_ESH \
-DSHOPT_VSH -DSHOPT_SUID_EXEC -c sh/userinit.c
xec.o : sh/xec.c FEATURE/locale FEATURE/externs FEATURE/time \
include/builtins.h FEATURE/dynamic FEATURE/options \
include/test.h include/jobs.h FEATURE/ttys \
include/shnodes.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/variables.h include/fcin.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c sh/xec.c
limits.o : data/limits.c include/ulimit.h FEATURE/time FEATURE/rlimits \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
data/limits.c
msg.o : data/msg.c include/national.h include/edit.h FEATURE/setjmp \
FEATURE/options include/jobs.h FEATURE/ttys \
include/builtins.h FEATURE/dynamic include/history.h \
include/timeout.h include/shlex.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_SUID_EXEC \
-DKSHELL -DSHOPT_ESH -DSHOPT_VSH -c data/msg.c
strdata.o : data/strdata.c include/streval.h FEATURE/options
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c data/strdata.c
testops.o : data/testops.c include/test.h include/shtable.h
${CC} ${CCFLAGS} -Iinclude -c data/testops.c
keywords.o : data/keywords.c FEATURE/options include/shlex.h \
include/shtable.h ${PACKAGE_ast_INCLUDE}/ast/hash.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c data/keywords.c
options.o : data/options.c include/shtable.h include/name.h \
FEATURE/options include/shell.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c data/options.c
signals.o : data/signals.c include/fault.h FEATURE/sigfeatures \
FEATURE/setjmp include/shtable.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -c \
data/signals.c
aliases.o : data/aliases.c include/name.h include/shtable.h \
FEATURE/dynamic FEATURE/options \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c data/aliases.c
builtins.o : data/builtins.c FEATURE/cmds include/name.h \
include/shtable.h include/shell.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -DKSHELL -c data/builtins.c
FEATURE/cmds : features/cmds
iffe set cc ${CC} ${CCFLAGS} ${LDFLAGS} : ref $${mam_cc_L+-L.} \
$${mam_cc_L+-L${PACKAGE_ast_LIB}} ${mam_cc_static} ${mam_libm} \
${mam_cc_dynamic} ${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libi} ${mam_cc_dynamic} ${mam_libdl} \
${mam_libdld} ${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} \
${mam_libast} : run features/cmds
variables.o : data/variables.c include/name.h include/shtable.h \
include/shell.h FEATURE/dynamic FEATURE/options \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DSHOPT_VSH \
-DSHOPT_SUID_EXEC -DSHOPT_ESH -c data/variables.c
lexstates.o : data/lexstates.c include/lexstates.h FEATURE/options
${CC} ${CCFLAGS} -I. -Iinclude -DSHOPT_VSH -DSHOPT_SUID_EXEC -DSHOPT_ESH \
-c data/lexstates.c
emacs.o : edit/emacs.c include/terminal.h include/edit.h FEATURE/setjmp \
FEATURE/options include/history.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_ESH -DSHOPT_VSH -DSHOPT_SUID_EXEC -c edit/emacs.c
vi.o : edit/vi.c FEATURE/time include/terminal.h include/edit.h \
FEATURE/setjmp FEATURE/options include/history.h \
include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h \
${PACKAGE_ast_INCLUDE}/ast/error.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_ESH -DSHOPT_VSH -DSHOPT_SUID_EXEC -c edit/vi.c
shcomp : shcomp.o libshell.a
${CC} ${CCFLAGS} ${LDFLAGS} $${mam_cc_L+-L.} $${mam_cc_L+-L${PACKAGE_ast_LIB}} \
-o shcomp shcomp.o libshell.a ${mam_libcmd} ${mam_libast} \
${mam_cc_static} ${mam_libm} ${mam_cc_dynamic} ${mam_cc_static} \
${mam_libjobs} ${mam_cc_dynamic} ${mam_cc_static} ${mam_libi} \
${mam_cc_dynamic} ${mam_libdl} ${mam_libdld} ${mam_cc_static} \
${mam_libintl} ${mam_cc_dynamic} ${mam_libast}
shcomp.o : sh/shcomp.c include/io.h ${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct FEATURE/options include/shnodes.h \
include/defs.h include/shell.h include/argnod.h \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/history.h
${CC} ${CCFLAGS} -I. -Iinclude -I${PACKAGE_ast_INCLUDE}/ast -DKSHELL \
-DSHOPT_SUID_EXEC -DSHOPT_VSH -DSHOPT_ESH -c sh/shcomp.c
ksh.msg : data/limits.c include/ulimit.h FEATURE/time FEATURE/rlimits \
${PACKAGE_ast_INCLUDE}/ast/ast.h data/msg.c \
include/national.h include/edit.h FEATURE/setjmp \
FEATURE/options include/jobs.h FEATURE/ttys \
include/builtins.h FEATURE/dynamic include/history.h \
include/timeout.h include/shlex.h include/io.h \
${PACKAGE_ast_INCLUDE}/ast/sfio.h \
${PACKAGE_ast_INCLUDE}/ast/ast.h include/path.h \
FEATURE/acct include/defs.h include/shell.h \
include/argnod.h include/fault.h FEATURE/sigfeatures \
data/strdata.c include/streval.h FEATURE/options \
data/testops.c include/test.h include/shtable.h \
data/keywords.c FEATURE/options include/shlex.h \
include/shtable.h ${PACKAGE_ast_INCLUDE}/ast/hash.h \
data/options.c include/shtable.h include/name.h \
FEATURE/options include/shell.h data/signals.c \
include/fault.h FEATURE/sigfeatures FEATURE/setjmp \
include/shtable.h ${PACKAGE_ast_INCLUDE}/ast/ast.h \
data/aliases.c include/name.h include/shtable.h \
FEATURE/dynamic FEATURE/options \
${PACKAGE_ast_INCLUDE}/ast/ast.h data/builtins.c \
FEATURE/cmds include/name.h include/shtable.h \
include/shell.h data/variables.c include/name.h \
include/shtable.h include/shell.h FEATURE/dynamic \
FEATURE/options ${PACKAGE_ast_INCLUDE}/ast/ast.h \
data/lexstates.c include/lexstates.h FEATURE/options
grep '[ ]e_[a-z].*".*[^\][a-z].*"' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| grep -v /bin/ | grep -v /usr/ | grep -v /dev/ | grep \
-v /etc/ | grep -v A__z | sed 's/.*=[ ]*\(".*"\);.*/\1/' \
| sort | uniq > ksh.msg$(newline) \
grep '[ ]sh_opt.*".*[^\][a-z].*"' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| sed 's/.*=[ ]*\(".*"\);.*/\1/' >> ksh.msg$(newline) \
grep '[ ]is_[a-z].*".*[^\][a-z].*"' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| sed 's/.*=[ ]*\(".*"\);.*/\1/' >> ksh.msg$(newline) \
grep '[ ]e_notset' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| sed 's/.*"....\(.*"\).*/"\1/' >> ksh.msg$(newline) \
grep '[ ]e_subst' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| sed 's/.*"....\(.*"\).*/"\1/' >> ksh.msg$(newline) \
grep '[ ]e_file' data/limits.c data/msg.c data/strdata.c \
data/testops.c data/keywords.c data/options.c data/signals.c \
data/aliases.c data/builtins.c data/variables.c data/lexstates.c \
| sed 's/.*"....\(.*"\).*/"\1/' >> ksh.msg$(newline) \
grep ',$$' data/signals.c | sed 's/.*\(".*"\),/\1/' | sort | uniq \
>> ksh.msg
shell : libshell.a
suid_exec : suid_exec.o
${CC} ${CCFLAGS} ${LDFLAGS} $${mam_cc_L+-L.} $${mam_cc_L+-L${PACKAGE_ast_LIB}} \
-o suid_exec suid_exec.o ${mam_cc_static} ${mam_libm} ${mam_cc_dynamic} \
${mam_cc_static} ${mam_libjobs} ${mam_cc_dynamic} ${mam_cc_static} \
${mam_libi} ${mam_cc_dynamic} ${mam_libdl} ${mam_libdld} \
${mam_cc_static} ${mam_libintl} ${mam_cc_dynamic} ${mam_libast}
suid_exec.o : sh/suid_exec.c ${PACKAGE_ast_INCLUDE}/ast/error.h \
${PACKAGE_ast_INCLUDE}/ast/sig.h \
${PACKAGE_ast_INCLUDE}/ast/ls.h FEATURE/externs \
${PACKAGE_ast_INCLUDE}/ast/ast.h
${CC} ${CCFLAGS} -I. -I${PACKAGE_ast_INCLUDE}/ast -c sh/suid_exec.c
${INSTALLROOT}/bin :
set -$(newline) \
if test ! -d ${INSTALLROOT}/bin$(newline) \
then set -x && mkdir -p ${INSTALLROOT}/bin 2>/dev/null && set - \
||$(newline) \
{$(newline) \
test -d ./-p && rm -rf ./-p$(newline) \
p=$(newline) \
for d in `echo ${INSTALLROOT}/bin | sed -e 's%\\(.\\)/%\\1 %g'`$(newline) \
do case \$$p in$(newline) \
"") p=\$$d ;;$(newline) \
*) p=\$$p/\$$d ;;$(newline) \
esac$(newline) \
case \$$d in$(newline) \
.|..) ;;$(newline) \
*) if test ! -d \$$p$(newline) \
then rm -f \$$p$(newline) \
set -x && mkdir \$$p && set -$(newline) \
fi$(newline) \
;;$(newline) \
esac$(newline) \
done$(newline) \
} && set -x $(newline) \
fi
${INSTALLROOT}/bin/ksh : ksh
{ mv ${INSTALLROOT}/bin/ksh ${INSTALLROOT}/bin/ksh.old 2>/dev/null; \
cp ksh ${INSTALLROOT}/bin/ksh 2>/dev/null ;} \
|| true
${INSTALLROOT}/man/man1 :
set -$(newline) \
if test ! -d ${INSTALLROOT}/man/man1$(newline) \
then set -x && mkdir -p ${INSTALLROOT}/man/man1 2>/dev/null && set \
- ||$(newline) \
{$(newline) \
test -d ./-p && rm -rf ./-p$(newline) \
p=$(newline) \
for d in `echo ${INSTALLROOT}/man/man1 | sed -e 's%\\(.\\)/%\\1 \
%g'`$(newline) \
do case \$$p in$(newline) \
"") p=\$$d ;;$(newline) \
*) p=\$$p/\$$d ;;$(newline) \
esac$(newline) \
case \$$d in$(newline) \
.|..) ;;$(newline) \
*) if test ! -d \$$p$(newline) \
then rm -f \$$p$(newline) \
set -x && mkdir \$$p && set -$(newline) \
fi$(newline) \
;;$(newline) \
esac$(newline) \
done$(newline) \
} && set -x $(newline) \
fi
${INSTALLROOT}/man/man1/sh.1 : sh.1
{ mv ${INSTALLROOT}/man/man1/sh.1 ${INSTALLROOT}/man/man1/sh.1.old \
2>/dev/null; cp sh.1 ${INSTALLROOT}/man/man1/sh.1 2>/dev/null \
;} || true
${INSTALLROOT}/lib :
set -$(newline) \
if test ! -d ${INSTALLROOT}/lib$(newline) \
then set -x && mkdir -p ${INSTALLROOT}/lib 2>/dev/null && set - \
||$(newline) \
{$(newline) \
test -d ./-p && rm -rf ./-p$(newline) \
p=$(newline) \
for d in `echo ${INSTALLROOT}/lib | sed -e 's%\\(.\\)/%\\1 %g'`$(newline) \
do case \$$p in$(newline) \
"") p=\$$d ;;$(newline) \
*) p=\$$p/\$$d ;;$(newline) \
esac$(newline) \
case \$$d in$(newline) \
.|..) ;;$(newline) \
*) if test ! -d \$$p$(newline) \
then rm -f \$$p$(newline) \
set -x && mkdir \$$p && set -$(newline) \
fi$(newline) \
;;$(newline) \
esac$(newline) \
done$(newline) \
} && set -x $(newline) \
fi
${INSTALLROOT}/lib/libshell.a : libshell.a
{ mv ${INSTALLROOT}/lib/libshell.a ${INSTALLROOT}/lib/libshell.a.old \
2>/dev/null; cp libshell.a ${INSTALLROOT}/lib/libshell.a \
2>/dev/null ;} || true$(newline) \
(ranlib ${INSTALLROOT}/lib/libshell.a) >/dev/null 2>&1 || true
${INSTALLROOT}/man/man3 :
set -$(newline) \
if test ! -d ${INSTALLROOT}/man/man3$(newline) \
then set -x && mkdir -p ${INSTALLROOT}/man/man3 2>/dev/null && set \
- ||$(newline) \
{$(newline) \
test -d ./-p && rm -rf ./-p$(newline) \
p=$(newline) \
for d in `echo ${INSTALLROOT}/man/man3 | sed -e 's%\\(.\\)/%\\1 \
%g'`$(newline) \
do case \$$p in$(newline) \
"") p=\$$d ;;$(newline) \
*) p=\$$p/\$$d ;;$(newline) \
esac$(newline) \
case \$$d in$(newline) \
.|..) ;;$(newline) \
*) if test ! -d \$$p$(newline) \
then rm -f \$$p$(newline) \
set -x && mkdir \$$p && set -$(newline) \
fi$(newline) \
;;$(newline) \
esac$(newline) \
done$(newline) \
} && set -x $(newline) \
fi
${INSTALLROOT}/man/man3/nval.3 : nval.3
{ mv ${INSTALLROOT}/man/man3/nval.3 ${INSTALLROOT}/man/man3/nval.3.old \
2>/dev/null; cp nval.3 ${INSTALLROOT}/man/man3/nval.3 2>/dev/null \
;} || true
${INSTALLROOT}/include/ast :
set -$(newline) \
if test ! -d ${INSTALLROOT}/include/ast$(newline) \
then set -x && mkdir -p ${INSTALLROOT}/include/ast 2>/dev/null && \
set - ||$(newline) \
{$(newline) \
test -d ./-p && rm -rf ./-p$(newline) \
p=$(newline) \
for d in `echo ${INSTALLROOT}/include/ast | sed -e 's%\\(.\\)/%\\1 \
%g'`$(newline) \
do case \$$p in$(newline) \
"") p=\$$d ;;$(newline) \
*) p=\$$p/\$$d ;;$(newline) \
esac$(newline) \
case \$$d in$(newline) \
.|..) ;;$(newline) \
*) if test ! -d \$$p$(newline) \
then rm -f \$$p$(newline) \
set -x && mkdir \$$p && set -$(newline) \
fi$(newline) \
;;$(newline) \
esac$(newline) \
done$(newline) \
} && set -x $(newline) \
fi
${INSTALLROOT}/include/ast/nval.h : include/nval.h
proto -p -s -c AT\&T\ Bell\ Laboratories include/nval.h > 1.${COTEMP}.x$(newline) \
if cmp -s ${INSTALLROOT}/include/ast/nval.h 1.${COTEMP}.x$(newline) \
then rm -f 1.${COTEMP}.x$(newline) \
else mv 1.${COTEMP}.x ${INSTALLROOT}/include/ast/nval.h$(newline) \
fi
${INSTALLROOT}/include/ast/shell.h : include/shell.h
proto -p -s -c AT\&T\ Bell\ Laboratories include/shell.h > 1.${COTEMP}.x$(newline) \
if cmp -s ${INSTALLROOT}/include/ast/shell.h 1.${COTEMP}.x$(newline) \
then rm -f 1.${COTEMP}.x$(newline) \
else mv 1.${COTEMP}.x ${INSTALLROOT}/include/ast/shell.h$(newline) \
fi
${INSTALLROOT}/bin/suid_exec : suid_exec
{ mv ${INSTALLROOT}/bin/suid_exec ${INSTALLROOT}/bin/suid_exec.old \
2>/dev/null; cp suid_exec ${INSTALLROOT}/bin/suid_exec 2>/dev/null \
;} || true
${INSTALLROOT}/bin/shcomp : shcomp
{ mv ${INSTALLROOT}/bin/shcomp ${INSTALLROOT}/bin/shcomp.old 2>/dev/null; \
cp shcomp ${INSTALLROOT}/bin/shcomp 2>/dev/null \
;} || true

View File

@@ -0,0 +1,307 @@
:
#
# Glenn Fowler
# AT&T Bell Laboratories
#
# make abstract machine executor with state
#
# @(#)mamexec (gsf@research.att.com) 07/17/94
#
# mamexec [ -dfins ] [ target ... ] < mam-file
#
# NOTE: variables defined in this script may conflict with
# mam-file variables
#
_command_=mamexec
_debug_=:
_diff_=.
_error_='exit 1'
_exec_=eval
_force_=
_list_=
_same_=.
_set_=
_silent_=
_state_list_=MAMlist
_state_time_=MAMtime
_tmp_=/tmp/mam.$$.mam
trap 'rm -f $_tmp_' 0
trap 'exit 2' 1 2
while :
do case $# in
0) break ;;
esac
case $1 in
--) shift
break
;;
-*) case $1 in
-*[abceghjklmopqrtuvwxyz_A-Z0-9]*) # [!...] not portable
echo "Usage: $_command_ [ -dfins ] [ target ... ] < mam-file" >&2; exit 2
;;
*) case $1 in
*d*) _debug_="eval echo $_command_: debug: >&2" ;;
esac
case $1 in
*f*) _force_=1 ;;
esac
case $1 in
*i*) _error_=: ;;
esac
case $1 in
*n*) _exec_=echo ;;
esac
case $1 in
*s*) _silent_=1 ;;
esac
;;
esac
;;
*) break
;;
esac
shift
done
_select_=
while :
do case $# in
0) break ;;
esac
case $1 in
*=*) eval $1
;;
*) case $_select_ in
"") _select_=$1 ;;
*) _select_="$_select_|$1" ;;
esac
;;
esac
shift
done
case $_select_ in
"") _select_="*" ;;
esac
(set -e; false || true) && _set_=e || echo $_command_: command errors ignored because of shell botch >&2
case $_silent_ in
"") _set_=x$_set_
;;
*) case $_exec_ in
"echo") _exec_=: ;;
esac
;;
esac
case $_exec_ in
"eval") _begin_="("
_end_=") </dev/null"
case $_set_ in
?*) _set_="set -$_set_;" ;;
esac
;;
*) _set_=
;;
esac
if test -f $_state_list_ -a -f $_state_time_
then mamstate $_state_list_ < $_state_list_ | sort > $_tmp_
for _i_ in `comm -12 $_state_time_ $_tmp_ | sed 's/ .*//'`
do case $_same_ in
.) _same_=$_i_ ;;
*) _same_="$_same_|$_i_" ;;
esac
done
fi
_index_=_
_match_=
case `(echo ok | (read -r a; echo $a) 2>/dev/null)` in
ok) _read_='read -r'
;;
*) # read strips \ -- thanks a lot
# tmp file avoids char at a time read
_read_=read
sed 's/\\/\\\\/g' > $_tmp_
exec < $_tmp_
rm -f $_tmp_
;;
esac
_old_=1
_ifs_=$IFS
while IFS=' '; $_read_ _op_ _arg_ _val_
do IFS=$_ifs_
case $_op_ in
"note") continue
;;
"info") case $_arg_ in
"mam") _old_= ;;
esac
continue
;;
"setv") eval _data_='$'$_arg_
case $_index_:$_data_ in
__*:*|*:)
case $_exec_ in
"eval") ;;
*) echo "$_arg_=$_val_" ;;
esac
eval $_arg_="$_val_" "</dev/null"
;;
esac
case $_arg_:$mam_cc_L in
"CC:") (
set -
mkdir /tmp/mam$$
cd /tmp/mam$$
echo 'main(){return 0;}' > main.c
code=1
if $CC -c main.c 2>/dev/null
then if $CC -L. main.o -lc 2>/dev/null
then $CC -L. main.o -lc > libc.a 2>/dev/null || code=0
fi
fi
cd /tmp
rm -rf /tmp/mam$$
exit $code
) </dev/null && mam_cc_L=' '
;;
esac
continue
;;
"make") eval _name_$_index_=$_name_
eval _prev_$_index_=$_prev_
eval _cmds_$_index_='"$_cmds_"'
eval _attr_$_index_=$_attr_
eval _name_=$_arg_
_prev_=$_index_
case " $_val_ " in
*" metarule "*) _attr_=m$_attr_ ;;
esac
_cmds_=
eval " case \"$_name_\" in
$_select_)
case \"$_select_\" in
\"*\") _select_=$_name_ ;;
esac
_match_=1
_attr_=x$_attr_
;;
esac"
case $_force_ in
"") eval " case \"$_name_\" in
$_diff_)_attr_=u$_attr_ ;;
$_same_);;
*) _attr_=u$_attr_ ;;
esac"
;;
*) _attr_=u$_attr_
;;
esac
case $_attr_ in
*u*) case $_diff_ in
.) _diff_=$_name_ ;;
*) _diff_="$_diff_|$_name_" ;;
esac
;;
esac
_index_=_$_index_
eval _name_$_index_=$_name_
eval _prev_$_index_=$_prev_
eval _cmds_$_index_=$_cmds_
eval _attr_$_index_=$_attr_
eval _list_='"'"$_list_"'
'$_name_'"'
continue
;;
"prev") case $_force_ in
"") eval " case \"$_arg_\" in
$_diff_)_attr_=u$_attr_ ;;
$_same_) ;;
*) _attr_=u$_attr_ ;;
esac"
;;
*) _attr_=u$_attr_
;;
esac
continue
;;
esac
case $_index_ in
_) echo $_op_: missing make op >&2; continue ;;
esac
case $_op_ in
"attr") case $_val_ in
"meta"|"suff") _attr_=m$_attr_ ;;
esac
;;
"exec"|"....")
case $_old_ in
"") _arg_=$_val_
;;
*) case $_val_ in
?*) _arg_="$_arg_ $_val_" ;;
esac
;;
esac
case $_cmds_ in
"") _cmds_=$_arg_
;;
*) _cmds_="$_cmds_
$_arg_"
;;
esac
;;
"done") eval _arg_=$_arg_
_prop_=
case $_arg_ in
$_name_)case $_attr_ in
*m*) ;;
*x*u*|*u*x*)
case $_cmds_ in
"") case $_attr_ in
*u*) _prop_=u ;;
esac
;;
*) $_exec_ "$_begin_$_set_$_cmds_$_end_" ||
{
_code_=$?
case $_set_ in
*-*e*) ;;
*) case $_cmds_ in
*if*then*fi*|"||") _code_=0 ;;
esac
;;
esac
case $_code_ in
0) ;;
*) echo "*** exit code $_code_ making $_name_" >&2
$_error_
;;
esac
}
_prop_=u
;;
esac
;;
esac
_index_=$_prev_
eval _name_='$'_name_$_index_
eval _prev_='$'_prev_$_index_
eval _cmds_='$'_cmds_$_index_
eval _attr_=$_prop_'$'_attr_$_index_
;;
*) echo $_val_: $_op_ $_name_ expected >&2
;;
esac
;;
esac
done
IFS=$_ifs_
case $_match_ in
"") echo "$_command_: don't know how to make $_select_" >&2; $_error_ ;;
esac
case $_exec_ in
"eval") echo "$_list_" > $_state_list_
mamstate $_state_list_ < $_state_list_ | sort > $_state_time_
;;
esac

View File

@@ -0,0 +1,79 @@
/* $XConsortium: mamstate.c /main/3 1995/11/01 16:25:23 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/*
* AT&T Bell Laboratories
* make abstract machine file state support
*
* mamstate reference [ file ... | <files ]
*
* stdout is list of <file,delta> pairs where delta
* is diff between reference and file times
* non-existent files are not listed
*/
#if !lint
static char id[] = "\n@(#)mamstate (AT&T Bell Laboratories) 06/26/89\0\n";
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
main(argc, argv)
int argc;
register char** argv;
{
register char* s;
register int c;
long ref;
struct stat st;
char buf[1024];
if (!(s = *++argv) || stat(s, &st))
{
fprintf(stderr, "Usage: mamstate reference [ file ... | <files ]\n");
exit(1);
}
ref = (long)st.st_mtime;
if (s = *++argv) do
{
if (!stat(s, &st))
printf("%s %ld\n", s, (long)st.st_mtime - ref);
} while (s = *++argv);
else do
{
s = buf;
while ((c = getchar()) != EOF && c != ' ' && c != '\n')
if (s < buf + sizeof(buf) - 1) *s++ = c;
if (s > buf)
{
*s = 0;
if (!stat(buf, &st))
printf("%s %ld\n", buf, (long)st.st_mtime - ref);
}
} while (c != EOF);
exit(0);
}

View File

@@ -0,0 +1,433 @@
.\" $XConsortium: nval.3 /main/3 1995/11/01 16:25:36 rswiston $
.TH NVAL 3 "12 Nov 1992"
.PP
\fBNAME\fP
.PP
\fBnval\fR \- a \f5ksh\fP name/value library
.PP
\fBSYNOPSIS\fP
.ta .8i 1.6i 2.4i 3.2i 4.0i 4.8i
.PP
.nf
.ft 5
#include <nval.h>
Namval_t *nv_open(const char *\fIname\fP, Hashtab_t *\fItable\fP, int \fIflags\fP);
void nv_close(Namval_t *\fInp\fP);
Hashtab_t *nv_getscope(int \fIindex\fP);
char *nv_getval(Namval_t *\fInp\fP);
double nv_getnum(Namval_t *\fInp\fP);
unsigned nv_isattr(Namval_t *\fInp\fP, unsigned \fIflags\fP);
char *nv_name(Namval_t *\fInp\fP);
void nv_newattr(Namval_t *\fInp\fP, unsigned \fIflags\fP, int \fIsize\fP);
void nv_putval(Namval_t *\fInp\fP, const char *\fIval\fP, int \fIflags\fP);
int nv_size(Namval_t *\fInp\fP);
Namfun_t *nv_stack(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP);
int nv_scan(Hashtab_t *\fItable\fP, void(*\fIfn\fP)(Namval_t*,int,int));
void nv_unset(Namval_t *\fInp\fP);
Namarr_t *nv_setarray(Namval_t *\fInp\fP,void*(*\fIfun\fP)(Namval_t*,const char*,int));
Namval_t *nv_putsub(Namval_t *\fInp\fP, char *\fIname\fP, long \fImode\fP);
char *nv_getsub(Namval_t *\fInp\fP);
int nv_nextsub(Namval_t *\fInp\fP);
int nv_aindex(Namval_t *\fInp\fP);
void nv_setref(Namval_t *\fInp\fP);
void nv_setvtree(Namval_t *\fInp\fP);
char *nv_getv(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP);
double nv_getn(Namval_t *\fInp\fP, Namfun_t *\fIfp\fP);
void nv_putv(Namval_t *\fInp\fP, const char *\fIval\fP, int \fIflags\fP, Namfun_t *\fIfp\fP);
char *nv_setdisc(Namval_t *\fInp\fP, const char *\fIa\fP, Namval_t *\fIf\fP, Namfun_t *\fIfp\fP);
Namval_t *nv_create(Namval_t *\fInp\fP, const char *\fIname\fP, Namfun_t *\fIfp\fP);
.fR
.fi
.PP
\fBDESCRIPTION\fP
.PP
\fINval\fP is a library of functions for interacting with name-value
pairs as used in \f5ksh\fP.
It is built on top an the extensible hashing library facility
in \f5libast\fP. (See hash(3)).
Each name-value pair is represented by a
type named \f5Namval_t\fP.
A \f5Namval_t\fP contains the name, value and
attributes of a variable.
Some attributes can have an associated number that
represents the field width, arithmetic base, or precision.
Additionally, each name-value pair can be associated with
one or more processing disciplines that affect
its behavior.
.PP
The function \f5nv_open()\fP returns a pointer to a name-value
pair corresponding to the given \fIname\fP.
It can also assign a value and give attributes to a name-value pair.
The argument \fItable\fP defines the table to search.
A \f5NULL\fP value causes the shell variable table to be searched.
It is possible for an application to create additional tables
with the hash library.
In addition, the \f5nv_getscope()\fP function returns a ponter to
the hash table for the scope corresponding to \fIindex\fP,
or \f5NULL\fP if no such table exists.
A value of \f50\fP for \fIindex\fP indicates the global scope.
A positive \fIindex\fP indicates the number of levels back
on the function call stack to find the scope.
The \fIflags\fP argument consists of the bitwise-or of zero or more
of the attributes listed later and zero or more of the following:
.IP
\f5NV_VARNAME\fP:
An invalid variable name causes an error.
.IP
\f5NV_IDENTIFIER\fP:
A variable name that is not an identifier causes an error.
.IP
\f5NV_ASSIGN\fP:
The \fIname\fP argument can contain an assignment.
.IP
\f5NV_NOARRAY\fP:
The \fIname\fP argument cannot contain a subscript.
.IP
\f5NV_NOREF\fP:
Do not follow references when finding the name-value pair.
.IP
\f5NV_NOADD\fP:
The name-value pair will not be added if it doesn't exist.
Instead, a \f5NULL\fP pointer will be returned.
.IP
\f5NV_NOSCOPE\fP:
Only the top level scope is used.
.PP
If a name-value pair by this name does not already exist, it is
created unless \fIflags\fP contains the \f5NV_NOADD\fP flag.
If neither \f5NV_VARNAME\fP nor \f5NV_IDENTIFIER\fP is
specified, and \f5NV_NOASSIGN\fP is specified,
then no validity check is performed on the \fIname\fP argument
and no further processing is performed.
Otherwise, if \f5NV_NOASSIGN\fP is not specified, then the characters up
to the first \f5=\fP are used to find the name-value pair,
and the characters after the \f5=\fP are used to define
the value that will be assigned to this name-value pair.
If \fIname\fP does not contain an \f5=\fP, than no assignment
will be made.
If the first identifier in \fIname\fP is a reference and is not
preceded by a \fB.\fP,
it will be replaced by the value of the reference
to find the name of a variable.
Unless \fIflags\fP contains the \f5NV_NOREF\fP flag,
if the name-value pair give by \fIname\fP has the \f5NV_REF\fP
attribute, it will be replaced by the variable whose name
is the value of this name-value pair.
Unless prohibited by the \f5NV_NOASSIGN\fP \fIflags\fP argument,
the \fIname\fP variable can contain an \f5=\fP
and a value that will be assigned to the name-value pair.
Any attributes appearing in the \fIflags\fP argument
will be applied to the name-value pair after any value is assigned.
.PP
The \f5nv_close()\fP indicates that the pointer returned by
\f5nv_open()\fP will not be referenced again. If the
name-value pair is unset, and not referenced elsewhere,
the name-value pair may be freed.
.PP
The \f5nv_name()\fP function returns the name of the given name-value
pair \fInp\fP.
The \f5nv_size()\fP function returns the size of the field for
justified variables, the arithmetic base for integer variables,
and the precision or number of places after the decimal point
for floating point variables.
The \f5nv_getval()\fP function returns the value of the given
name-value pair as a string. A \f5NULL\fP return value indicates
that the name-value pair is unset.
The \f5nv_getnum()\fP function returns the value of the given
name-value pair as a double precision number.
For name-value pairs without the \f5NV_INTEGER\fP attribute,
the string value is evaluated as an arithmetic expression to
arrive at a numerical value.
.PP
The \f5nv_putval()\fP function is used to assign a \fIvalue\fP to
the name-value pair \fInp\fP.
The \fIflags\fP argument consists zero or more of the bitwise-or
of \f5NV_INTEGER\fP, \f5NV_RDONLY\fP, \f5NV_REF\fP, and \f5NV_NOFREE\fP.
The presence of \f5NV_RDONLY\fP allows the assignment to occur
even if the name-value pair has the \f5NV_RDONLY\fP attribute.
The presence of \f5NV_INTEGER\fP indicates that the \fIvalue\fP
argument is actually a pointer to a double precision number
containing the value for this name-value pair.
The presence of \f5NV_REF\fP indicates that the \fIvalue\fP
argument is actually a pointer to a name-value pair
and \f5np\fP should become a reference to this name-value pair.
If \f5NV_NOFREE\fP is specified, \fIvalue\fP itself becomes
the value of the name-value pair \fInp\fP.
Otherwise, a copy of the value is stored
as the value for \fInp\fP.
.PP
The \f5nv_unset()\fP function clears out the value and attributes
of the given name-value function but does not free the name-value
pair.
.PP
The following attributes can be associated with a name-value pair:
.IP
\f5NV_EXPORT\fP:
The export attribute.
.IP
\f5NV_RDONLY\fP:
The readonly attribute.
.IP
\f5NV_LTOU\fP:
Lower case characters are converted to upper case characters.
.IP
\f5NV_UTOL\fP:
Upper case characters are converted to lower case characters.
.IP
\f5NV_RJUST\fP:
Right justify and blank fill.
This attribute has an associated size that defines the
string length of the value.
.IP
\f5NV_LJUST\fP:
Left justify and blank fill.
This attribute has an associated size that defines the
string length of the value.
.IP
\f5NV_ZFILL\fP:
Without \f5NV_LJUST\fP, right justifies and fills with leading zeros.
With \f5NV_LJUST\fP, left justify and strip leading zeros.
Left justify and blank fill.
This attribute has an associated size that defines the
string length of the value.
.IP
\f5NV_TAGGED\fP:
Indicates the tagged attribute.
.IP
\f5NV_INTEGER\fP:
Causes value to be represented by a number.
This attribute has an associated number that defines the
arithmetic base to be used when the value is expanded as a string.
.IP
\f5NV_DOUBLE\fP:
Used in conjunction with \f5NV_INTEGER\fP to cause value
to be stored as a double precision floating point number.
This attribute has an associated number that defines the
number of places after the decimal point to be used when
the value is expanded as a string.
.IP
\f5NV_EXPNOTE\fP:
Used in conjunction with \f5NV_INTEGER\fP and \f5NV_DOUBLE\fP to
cause the value to be represented in scientific notation when
expanded as a string.
This attribute has an associated number that defines the
the precision of the mantissa.
.IP
\f5NV_REF\fP:
The name-value pair is a name reference variable.
.PP
The \f5nv_isattr()\fP function can test whether or not any of
the attributes given by \fIflags\fP is set.
The attribute \f5NV_ARRAY\fP can be used to test whether
or not the given name-value pair is an array.
The \f5nv_newattr()\fP function can be used to change the
attributes of the given name-value pair.
The \fIsize\fP argument is needed for attributes that require
an additional argument.
Changing the attribute may require changing the value
to agree with the new attributes.
For an array variable, each of the values will be changed.
.PP
The \f5nv_scan()\fP function is used to walk through
all name-value pairs in the table given by \fItable\fP.
If \fIfn\fP is non-zero, then this function will be executed
for each name-value pair in the table.
The number of elements in the table will be returned.
.PP
Disciplines provide a way to
intercept the lookup and assignment operations and to
extend the operations permitted on a name-value pair.
A discipline consists of a set of functions and related
data that are used to override and extend the operations
on a name-value pair.
A discipline is defined by the types
\f5Namfun_t\fP and \f5Namdisc_t\fP.
The \f5Namdisc_t\fP is not modified by any of these functions and
can therefore be shared by several name-value pairs.
It contains following public fields in the order listed:
.nf
\f5size_t dsize;\fP
\f5void (*putval)(Namval_t*,const char*,int,Namfun_t*);\fP
\f5char *(*getval)(Namval_t*,Namfun_t*);\fP
\f5double (*getnum)(Namval_t*,Namfun_t*);\fP
\f5char *(*setdisc)(Namval_t*,const char*,Namval_t*,Namfun_t*);\fP
\f5Namval_t *(*create)(Namval_t*,const char*,Namfun_t*);\fP
.fi
The \f5Namfun_t\fP type contains a member named
\f5disc\fP which points to a \f5Namdisc_t\fP structure.
To create a discipline with additional user data,
define a structure with an instance of \f5Namfun_t\fP
as the first element.
The \f5dsize\fP field of the \f5Namdisc_t\fP structure must be
the size of this structure. A value of 0,
indicates that there are no additional fields and is equivalent
to \f5sizeof(Namfun_t)\fP.
.PP
When a variable is referenced by calling the \f5nv_getval()\fP function,
the \f5getval()\fP discipline function is called with a pointer
to the name-value pair, \fInp\fP, and a pointer to the discipline,
\fIfp\fP.
Inside the \f5getval()\fP function, the \f5nv_getv()\fP function
can be called to get the value of the name-value pair that
would have resulted if the discipline were not used.
The \f5getnum()\fP discipline is called whenever a numerical
value is needed for the name-value pair \fInp\fP.
The \f5nv_getn()\fP function can be called from within
the \f5getnum()\fP discipline to get the value that would
have resulted if there were no \f5getnum()\fP discipline.
.PP
The \f5putval\fP\f5()\fP discipline function is used to
override the assignment of values
to a name-value pair.
It is called whenever a value is assigned with \f5nv_putval()\fP
or unset with \f5nv_unset()\fP.
When a name-value pair is unset, \f5putval\fP\f5()\fP
is called with \fIvalue\fP set to \f5NULL\fP.
The \f5nv_putv()\fP function is used within the \f5putval()\fP
to perform the assignment or unset that would have occurred
if the discipline had not been installed.
.PP
The \f5create()\fP discipline function is called from
\f5nv_open()\fP when the name-value pair for name containing a
.B \s+2.\s-2
doesn't exist, unless \f5NV_NOADD\fP was specified.
This function is passed the name-value pointer of the longest
parent name-value pair that exists, plus the remaining string.
The \f5create()\fP discipline function
must return the created name-value pair, otherwise the default action
will be taken.
If the name-value pair that is returned, is the same as the
one given, then the the behavior will be the same as if
an invalid name had been given to \f5nv_open()\fP.
The \f5nv_create()\fP function may be called within
the \f5create()\fP
discipline function
to perform the action that would have occurred
by an earlier discipline.
.PP
The \f5setdisc()\fP discipline function is used
to extend the set of available shell level discipline functions
associated with a name-value pair by allowing
functions whose name is of the
form \fIvarname\fP\f5.\fP\fIaction\fP to be defined.
By default, each name-value pair can have a \f5get\fP,
\f5set\fP, and \f5unset\fP discipline associated with it.
Whenever a function whose name is of the
form \fIvarname\fP\f5.\fP\fIaction\fP is defined or is unset,
and \fIaction\fP is not \f5get\fP,
\f5set\fP, or \f5unset\fP, the \fIsetdisc\fP\f5()\fP function is invoked
with the same argument format as \f5nv_setdisc\fP\f5()\fP.
The argument \fIf\fP points to the name-value pair associated
with the function being defined, or \f5NULL\fP if the function is
being unset.
If the given action \fIa\fP is not known by this discipline,
it should return the value returned by calling
\f5nv_setdisc(\fP\fInp\fP\f5,\fP\fIa\fP\f5,\fP\fIf\fP\f5,\fP\fIfp\fP\f5)\fP
so that it can be searched for in previously stacked disciplines.
Otherwise, the \fIsetdisc\fP\f5()\fP function should save the function
name-value pair pointer, and return a non-\f5NULL\fP value.
The name-value pointer to the function can be used to invoke
the function at an application defined point.
If the action \fIa\fP is \f5NULL\fP, then \fIf\fP points to
an action name instead of a name-value pair pointer.
The \fIsetdisc\fP\f5()\fP must return the
name of the action that follows the action name given by
\fIf\fP. If \fIf\fP is also \f5NULL\fP, the name of the first action
must be returned.
This allows an application to get the list of valid discipline
action names allowed by a given name-value pair.
.PP
A discipline is installed or removed with the
\f5nv_stack()\fP function.
If \fIfp\fP is non-\f5NULL\fP, the discipline is pushed onto
the stack of disciplines associated with the given name-value
pair \fInp\fP.
Otherwise, the most recently pushed discipline is popped
and returned.
.PP
The \f5nv_aindex()\fP function returns
the current index for
the indexed array given by the name-value pair pointer \fInp\fP.
The return value is negative if \fInp\fP refers to
an associative array.
.PP
The \f5nv_setarray()\fP function is used to create an associative array
from a name-value pair node.
The function \fIfun\fP defines the semantics of the associative
array.
Using \fIfun\fP equal to \f5nv_associative()\fP implements the default
associative array semantics
that are used with \f5typeset\ -A\fP.
The function \fIfun\fP will be called with third argument as follows:
.IP
\f5NV_AINIT\fP:
This will be called at initialization.
The function you supply must return a pointer to a structure
that contains the type \f5Namarr_t\fP as the first element.
All other calls receive this value as an argument.
.IP
\f5NV_AFREE\fP:
This will be called after all elements of the name-value pair have been
deleted and the array is to be freed.
.IP
\f5NV_ADELETE\fP:
The current element should be deleted.
.IP
\f5NV_ANEXT\fP:
This means that the array subscript should be advanced to the
next subscript. A \f5NULL\fP return indicates that there are
no more subscripts.
.IP
\f5NV_ANAME\fP:
The name of the current subscript must be returned.
.PP
If \fInp\fP refers to an array,
the \f5nv_getsub()\fP returns a pointer to
the name of the current subscript.
Otherwise, \f5nv_getsub()\fP
returns \f5NULL\fP.
.PP
The \f5nv_putsub()\fP function is used to
set the subscript for the next reference to \f5np\fP.
If the \f5name\fP argument is not \f5NULL\fP,
it defines the value of the next subscript.
The \f5mode\fP argument can contain one or more of the following flags:
.IP
\f5ARRAY_ADD\fP:
Add the subscript if not found.
Otherwise, \f5nv_putsub()\fP returns \f5NULL\fP if the
given subscript is not found.
.IP
\f5ARRAY_SCAN\fP:
Begin a walk through the subscripts starting at the subscript
given by \f5name\fP if given. Otherwise,
the walk is started from the beginning.
.IP
\f5ARRAY_UNDEF\fP:
This causes any current scan to terminate and leaves the
subscript in an undefined state.
.PP
If \f5ARRAY_ADD\fP is not given and the subscript
does not exist, a \f5NULL\fP value is returned.
.PP
The \f5nv_nextsub()\fP function is used to advance to the
next subscript.
It returns 0 if there are no more subscripts or if called
when not in a scan.
.PP
The \f5nv_setref()\fP function makes the name-value pair \f5np\fP
into a reference to the variable whose name is given by
the value of \f5np\fP.
.PP
The \f5nv_setvtree()\fP function makes the name-value pair \f5np\fP
into a tree structured variable so that \f5nv_getval()\fP
will return a string containing all the names and values of
children nodes in a format that can be used in
a shell compound assignment.
.PP
\fBAUTHOR\fP
David G. Korn (dgk@research.att.com).

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,306 @@
/* $XConsortium: apollo.c /main/4 1996/10/04 15:52:17 drk $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include <ast.h>
#include "defs.h"
#include <errno.h>
#ifdef apollo
#include "/sys/ins/base.ins.c"
#include "/sys/ins/pad.ins.c"
#include "/sys/ins/error.ins.c"
#include <sys/param.h> /* for maximum pathname length */
#include <apollo/sys/ubase.h>
#include <apollo/sys/name.h>
#include <apollo/error.h>
int pad_create __PARAM__((char *fname), (fname)) __OTORP__(char *fname;){
short oldfd = 1;
short newfd;
short size = 25;
long st;
pad_$create (*fname, (short)strlen(fname), pad_$edit, oldfd,
pad_$bottom, 0, size, newfd, st);
if (st != 0)
error(ERROR_system(1),e_open,"dm pad");
return(newfd);
}
pad_wait __PARAM__((int fd), (fd)) __OTORP__(int fd;){
long st;
pad_$edit_wait((stream_$id_t)fd, st);
return (st == 0 ? 0 : 1);
}
char *apollo_error __PARAM__((void), ()){
extern __MANGLE__ long unix_proc_$status;
char subsys[80], module[80], code[80];
short slen, mlen, clen;
static char retstr[256];
error_$get_text (unix_proc_$status, subsys, slen,
module, mlen, code, clen);
subsys[slen] = module[mlen] = code[clen] = 0;
if (clen == 0)
sprintf (code, "status 0x%08lx", unix_proc_$status);
if ( mlen )
sprintf(retstr, "%s (%s/%s)", code, subsys, module );
else
sprintf(retstr, "%s (%s)", code, subsys );
return (retstr);
}
/*
* declarations to support the apollo builtin commands
* rootnode, inlib, and ver.
*/
static char last_rootnode[MAXPATHLEN] = "/";
static char do_ver;
static char *preval = NULL, *sysval, *sysid = "SYSTYPE";
/*
* code to support the apollo builtin functions rootnode,
* inlib, and ver.
*/
int b_rootnode __PARAM__((int argn,char *argv[]), (argn, argv)) __OTORP__(int argn;char *argv[];){
if (argn == 1)
{ /* report current setting */
sfprintf(sfstdout,"%s\n",last_rootnode);
return(0);
}
if (!is_valid_rootnode(argv[1]))
sh_cfail(e_rootnode);
if (rootnode(argv[1]) != 0)
{
perror("rootnode: "); /* ? */
sh_cfail(e_rootnode);
}
if (argn == 2)
strcpy(last_rootnode, argv[1]);
else
{
sysval = argv[1];
sh_eval(sh_sfeval(argv),0);
if (rootnode(last_rootnode) != 0)
sh_cfail(e_rootnode);
}
return(0);
}
int b_ver __PARAM__((int argn,char *argv[]), (argn, argv)) __OTORP__(int argn;char *argv[];){
char *oldver;
short i1, i2;
std_$call unsigned char c_$decode_version(__VARARG__);
oldver = SYSTYPENOD->namval.cp;
if (argn == 1 || argn > 2)
{
sysval = NULL;
if (oldver)
preval = sysval = oldver;
}
if (argn == 1)
{
if (!oldver || !sysval)
sh_cfail(e_nover);
else
{
sfprintf(sfstdout,"%s\n",sysval);
}
}
else
{
if (!c_$decode_version (*argv[1], (short) strlen (argv[1]), i1, i2))
sh_cfail(e_badver);
else
{
if (argn == 2)
{
short namlen = strlen(sysid);
short arglen = strlen(argv[1]);
nv_unset(SYSTYPENOD);
nv_putval(SYSTYPENOD, argv[1],NV_RDONLY);
nv_onattr(SYSTYPENOD, NV_EXPORT | NV_NOFREE);
ev_$set_var (sysid, &namlen, argv[1], &arglen);
}
else
{
int fd;
short namlen = strlen(sysid);
short arglen = strlen(argv[1]);
sysval = argv[1];
argv = &argv[2];
sh_eval(sh_sfeval(argv),0);
ev_$set_var(sysid, &namlen, sysval, &arglen);
if((fd=path_open(argv[0],path_get(argv[0]))) < 0)
{
arglen = (short)strlen(preval);
ev_$set_var (sysid, &namlen, preval, &arglen);
error(ERROR_system(1),e_open,argv[0]);
}
close(fd);
sh_eval(sfopen(argv[0],"s"),0);
arglen = (short)strlen(preval);
ev_$set_var (sysid, &namlen, preval, &arglen);
}
}
}
return(sh.exitval);
}
/*
* rootnode.c - a chroot call which doesn't require you to be root...
*/
/*
* Changes:
01/24/88 brian Initial coding
*/
#ifndef NULL
# define NULL ((__V_ *) 0)
#endif
extern __MANGLE__ boolean
unix_fio_$status_to_errno __PROTO__((
status_$t & status,
char * pn,
short & pnlen
));
is_valid_rootnode __PARAM__((const char *path), (path)) __OTORP__(const char *path;){
if (geteuid() == 0)
return 1;
return (path[0] == '/' && path[1] == '/' && path[2] != '\0' &&
strchr(&path[2], '/') == NULL);
}
rootnode __PARAM__((char * path), (path)) __OTORP__(char * path;){
uid_$t dir_uid, rtn_uid;
name_$pname_t new_root_name, rest_path;
name_$name_t leaf;
short rest_len, leaf_len, err;
status_$t status;
strcpy(new_root_name, path);
name_$resolve_afayc(new_root_name, (short)strlen(new_root_name),
&dir_uid, &rtn_uid, rest_path, &rest_len, leaf, &leaf_len, &err, &status);
if (status.all != status_$ok) {
unix_fio_$status_to_errno(status, path, strlen(path));
return (-1);
}
name_$set_diru(rtn_uid, rest_path, (short) rest_len, name_$node_dir_type, &status);
if (status.all != status_$ok) {
unix_fio_$status_to_errno(status, path, strlen(path));
return(-1);
}
return(0);
}
#endif /* apollo */
/*
* Apollo system support library loads into the virtual address space
*/
int b_inlib(argc,argv)
char **argv;
{
register char *a1 = argv[1];
int status;
short len;
std_$call void loader_$inlib(__VARARG__);
if(sh.subshell)
sh_subfork();
if(a1)
{
len = strlen(a1);
loader_$inlib(*a1, len, status);
if(status!=0)
error(3, e_badinlib);
}
return(0);
}

View File

@@ -0,0 +1,560 @@
/* $XConsortium: args.c /main/3 1995/11/01 16:45:22 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include "path.h"
#include "builtins.h"
#include "terminal.h"
#ifdef SHOPT_KIA
# include "shlex.h"
# include "io.h"
#endif /* SHOPT_KIA */
#define NUM_OPTS 20
#define SORT 1
#define PRINT 2
static int arg_expand __PROTO__((struct argnod*,struct argnod**));
static void print_opts __PROTO__((Shopt_t,int));
#ifdef SHOPT_KIA
static char *kiafile;
#endif /* SHOPT_KIA */
static char *null;
static struct dolnod *argfor; /* linked list of blocks to be cleaned up */
static struct dolnod *dolh;
/* The following order is determined by sh_optset */
static const Shopt_t flagval[] =
{
0, SH_DICTIONARY|SH_NOEXEC, SH_INTERACTIVE, SH_RESTRICTED, SH_CFLAG,
SH_ALLEXPORT, SH_NOTIFY, SH_ERREXIT, SH_NOGLOB, SH_TRACKALL,
SH_KEYWORD, SH_MONITOR, SH_NOEXEC, SH_PRIVILEGED, SH_SFLAG, SH_TFLAG,
SH_NOUNSET, SH_VERBOSE, SH_XTRACE, SH_NOCLOBBER, 0
};
static char flagadr[NUM_OPTS+1];
/* ======== option handling ======== */
/*
* This routine turns options on and off
* The options "Micr" are illegal from set command.
* The -o option is used to set option by name
* This routine returns the number of non-option arguments
*/
int sh_argopts __PARAM__((int argc,register char *argv[]), (argc, argv)) __OTORP__(int argc;register char *argv[];){
register int n;
register Shopt_t newflags=sh.options, opt;
int setflag=0, action=0, trace=(int)sh_isoption(SH_XTRACE);
Namval_t *np = NIL(Namval_t*);
const char *cp;
int verbose;
if(argc>0)
setflag = 4;
else
argc = -argc;
while((n = optget(argv,setflag?sh_optset:sh_optksh)))
{
switch(n)
{
case 'A':
np = nv_open(opt_arg,sh.var_tree,NV_NOASSIGN|NV_ARRAY|NV_VARNAME);
if(*opt_option=='-')
nv_unset(np);
continue;
case 'o':
if(!opt_arg)
{
action = PRINT;
verbose = (*opt_option=='-');
continue;
}
n = sh_lookup(opt_arg,shtab_options);
opt = 1L<<n;
if(setflag && (opt&(1|SH_INTERACTIVE|SH_RESTRICTED)))
{
error(2, e_option, opt_arg);
error_info.errors++;
}
break;
case 's':
if(setflag)
{
action = SORT;
continue;
}
#ifdef SHOPT_KIA
goto skip;
case 'R':
if(setflag)
n = ':';
else
{
kiafile = opt_arg;
n = 'n';
}
/* FALL THRU */
skip:
#endif /* SHOPT_KIA */
default:
if(cp=strchr(sh_optksh,n))
opt = flagval[cp-sh_optksh];
break;
case ':':
error(2, opt_arg);
continue;
case '?':
error(ERROR_usage(2), opt_arg);
return(-1);
}
if(*opt_option=='-')
{
if(opt&(SH_VI|SH_EMACS|SH_GMACS))
newflags &= ~(SH_VI|SH_EMACS|SH_GMACS);
newflags |= opt;
}
else
{
if(opt==SH_XTRACE)
trace = 0;
newflags &= ~opt;
}
}
if(error_info.errors)
error(ERROR_usage(2),optusage(NIL(char*)));
/* check for '-' or '+' argument */
if((cp=argv[opt_index]) && cp[1]==0 && (*cp=='+' || *cp=='-') &&
strcmp(argv[opt_index-1],"--"))
{
opt_index++;
newflags &= ~(SH_XTRACE|SH_VERBOSE);
trace = 0;
}
if(trace)
sh_trace(argv,1);
argc -= opt_index;
argv += opt_index;
/* cannot set -n for interactive shells since there is no way out */
if(sh_isoption(SH_INTERACTIVE))
newflags &= ~SH_NOEXEC;
if(action==PRINT)
print_opts(newflags,verbose);
if(setflag)
{
if(action==SORT)
{
if(argc>0)
strsort(argv,argc,strcoll);
else
strsort(sh.st.dolv+1,sh.st.dolc,strcoll);
}
if((newflags&SH_PRIVILEGED) && !sh_isoption(SH_PRIVILEGED))
{
if((sh.userid!=sh.euserid && setuid(sh.euserid)<0) ||
(sh.groupid!=sh.egroupid && setgid(sh.egroupid)<0) ||
(sh.userid==sh.euserid && sh.groupid==sh.egroupid))
newflags &= ~SH_PRIVILEGED;
}
else if(!(newflags&SH_PRIVILEGED) && sh_isoption(SH_PRIVILEGED))
{
setuid(sh.userid);
setgid(sh.groupid);
if(sh.euserid==0)
{
sh.euserid = sh.userid;
sh.egroupid = sh.groupid;
}
}
if(np)
{
nv_setvec(np,argc,argv);
nv_close(np);
}
else if(argc>0 || ((cp=argv[-1]) && strcmp(cp,"--")==0))
sh_argset(argv-1);
}
else if(newflags&SH_CFLAG)
{
if(!(sh.comdiv = *argv++))
{
error(2,e_cneedsarg);
error(ERROR_usage(2),optusage(NIL(char*)));
}
argc--;
}
sh.options = newflags;
#ifdef SHOPT_KIA
if(kiafile)
{
if(!(shlex.kiafile=sfopen(NIL(Sfio_t*),kiafile,"w+")))
error(ERROR_system(3),e_create,kiafile);
if(!(shlex.kiatmp=sftmp(2*SF_BUFSIZE)))
error(ERROR_system(3),e_tmpcreate);
sfprintf(shlex.kiafile,"0;s;%s;1;%6d;;;;\n",sh_fmtq(argv[0]),1);
shlex.kiabegin = sftell(shlex.kiafile)-11;
shlex.parent = "0";
shlex.file_tree = hashalloc(sh.var_tree,HASH_set,HASH_ALLOCATE,0);
kiafile = 0;
}
#endif /* SHOPT_KIA */
return(argc);
}
/*
* returns the value of $-
*/
char *sh_argdolminus __PARAM__((void), ()){
register const char *cp=sh_optksh;
register char *flagp=flagadr;
while(cp< &sh_optksh[NUM_OPTS])
{
if(sh.options&flagval[cp-sh_optksh])
*flagp++ = *cp;
cp++;
}
*flagp = 0;
return(flagadr);
}
/*
* set up positional parameters
*/
void sh_argset __PARAM__((char *argv[]), (argv)) __OTORP__(char *argv[];){
sh_argfree(dolh,0);
dolh = sh_argcreate(argv);
/* link into chain */
dolh->dolnxt = argfor;
argfor = dolh;
sh.st.dolc = dolh->dolnum-1;
sh.st.dolv = dolh->dolval;
}
/*
* free the argument list if the use count is 1
* If count is greater than 1 decrement count and return same blk
* Free the argument list if the use count is 1 and return next blk
* Delete the blk from the argfor chain
* If flag is set, then the block dolh is not freed
*/
struct dolnod *sh_argfree __PARAM__((struct dolnod *blk,int flag), (blk, flag)) __OTORP__(struct dolnod *blk;int flag;){
register struct dolnod* argr=blk;
register struct dolnod* argblk;
if(argblk=argr)
{
if((--argblk->dolrefcnt)==0)
{
argr = argblk->dolnxt;
if(flag && argblk==dolh)
dolh->dolrefcnt = 1;
else
{
/* delete from chain */
if(argfor == argblk)
argfor = argblk->dolnxt;
else
{
for(argr=argfor;argr;argr=argr->dolnxt)
if(argr->dolnxt==argblk)
break;
if(!argr)
return(NIL(struct dolnod*));
argr->dolnxt = argblk->dolnxt;
argr = argblk->dolnxt;
}
free((__V_*)argblk);
}
}
}
return(argr);
}
/*
* grab space for arglist and copy args
* The strings are copied after the argment vector
*/
struct dolnod *sh_argcreate __PARAM__((register char *argv[]), (argv)) __OTORP__(register char *argv[];){
register struct dolnod *dp;
register char **pp=argv, *sp;
register int size=0,n;
/* count args and number of bytes of arglist */
while(sp= *pp++)
size += strlen(sp);
n = (pp - argv)-1;
dp=new_of(struct dolnod,n*sizeof(char*)+size+n);
dp->dolrefcnt=1; /* use count */
dp->dolnum = n;
dp->dolnxt = 0;
pp = dp->dolval;
sp = (char*)dp + sizeof(struct dolnod) + n*sizeof(char*);
while(n--)
{
*pp++ = sp;
sp = strcopy(sp, *argv++) + 1;
}
*pp = NIL(char*);
return(dp);
}
/*
* used to set new arguments for functions
*/
struct dolnod *sh_argnew __PARAM__((char *argi[], struct dolnod **savargfor), (argi, savargfor)) __OTORP__(char *argi[]; struct dolnod **savargfor;){
register struct dolnod *olddolh = dolh;
*savargfor = argfor;
dolh = 0;
argfor = 0;
sh_argset(argi);
return(olddolh);
}
/*
* reset arguments as they were before function
*/
void sh_argreset __PARAM__((struct dolnod *blk, struct dolnod *afor), (blk, afor)) __OTORP__(struct dolnod *blk; struct dolnod *afor;){
while(argfor=sh_argfree(argfor,0));
argfor = afor;
if(dolh = blk)
{
sh.st.dolc = dolh->dolnum-1;
sh.st.dolv = dolh->dolval;
}
}
/*
* increase the use count so that an sh_argset will not make it go away
*/
struct dolnod *sh_arguse __PARAM__((void), ()){
register struct dolnod *dh;
if(dh=dolh)
dh->dolrefcnt++;
return(dh);
}
/*
* Print option settings on standard output
* if mode==1 for -o format, otherwise +o format
*/
static void print_opts __PARAM__((Shopt_t oflags,register int mode), (oflags, mode)) __OTORP__(Shopt_t oflags;register int mode;){
register const Shtable_t *tp = shtab_options;
Shopt_t value;
if(mode)
sfputr(sfstdout,ERROR_translate(e_heading,1),'\n');
else
sfwrite(sfstdout,"set",3);
while(value=tp->sh_number)
{
value = 1L<<value;
if(mode)
{
char const *msg;
sfputr(sfstdout,tp->sh_name,' ');
sfnputc(sfstdout,' ',16-strlen(tp->sh_name));
if(oflags&value)
msg = e_on;
else
msg = e_off;
sfputr(sfstdout,ERROR_translate(msg,1),'\n');
}
else if(oflags&value)
sfprintf(sfstdout," -o %s",tp->sh_name);
tp++;
}
if(!mode)
sfputc(sfstdout,'\n');
}
/*
* build an argument list
*/
char **sh_argbuild __PARAM__((int *nargs, const struct comnod *comptr), (nargs, comptr)) __OTORP__(int *nargs; const struct comnod *comptr;){
register struct argnod *argp;
struct argnod *arghead=0;
{
register const struct comnod *ac = comptr;
/* see if the arguments have already been expanded */
if(!ac->comarg)
{
*nargs = 0;
return(&null);
}
else if(!(ac->comtyp&COMSCAN))
{
register struct dolnod *ap = (struct dolnod*)ac->comarg;
*nargs = ap->dolnum;
return(ap->dolval+ap->dolbot);
}
sh.lastpath = 0;
*nargs = 0;
if(ac)
{
argp = ac->comarg;
while(argp)
{
*nargs += arg_expand(argp,&arghead);
argp = argp->argnxt.ap;
}
argp = arghead;
}
}
{
register char **comargn;
register int argn;
register char **comargm;
argn = *nargs;
/* allow room to prepend args */
#ifdef SHOPT_VPIX
argn += 2;
#else
argn += 1;
#endif /* SHOPT_VPIX */
comargn=(char**)stakalloc((unsigned)(argn+1)*sizeof(char*));
comargm = comargn += argn;
*comargn = NIL(char*);
if(!argp)
{
/* reserve an extra null pointer */
*--comargn = 0;
return(comargn);
}
while(argp)
{
struct argnod *nextarg = argp->argchn.ap;
argp->argchn.ap = 0;
*--comargn = argp->argval;
if(!(argp->argflag&ARG_RAW))
sh_trim(*comargn);
if(!(argp=nextarg) || (argp->argflag&ARG_MAKE))
{
if((argn=comargm-comargn)>1)
strsort(comargn,argn,strcoll);
comargm = comargn;
}
}
return(comargn);
}
}
/* Argument expansion */
static int arg_expand __PARAM__((register struct argnod *argp, struct argnod **argchain), (argp, argchain)) __OTORP__(register struct argnod *argp; struct argnod **argchain;){
register int count = 0;
argp->argflag &= ~ARG_MAKE;
#ifdef SHOPT_DEVFD
if(*argp->argval==0 && (argp->argflag&ARG_EXP))
{
/* argument of the form (cmd) */
register struct argnod *ap;
int monitor, fd, pv[2];
ap = (struct argnod*)stakseek(ARGVAL);
ap->argflag |= ARG_MAKE;
ap->argflag &= ~ARG_RAW;
ap->argchn.ap = *argchain;
*argchain = ap;
count++;
stakwrite(e_devfdNN,8);
sh_pipe(pv);
fd = argp->argflag&ARG_RAW;
stakputs(fmtbase((long)pv[fd],10,0));
ap = (struct argnod*)stakfreeze(1);
sh.inpipe = sh.outpipe = 0;
if(monitor = (sh_isstate(SH_MONITOR)!=0))
sh_offstate(SH_MONITOR);
if(fd)
{
sh.inpipe = pv;
sh_exec((union anynode*)argp->argchn.ap,(int)sh_isstate(SH_ERREXIT));
}
else
{
sh.outpipe = pv;
sh_exec((union anynode*)argp->argchn.ap,(int)sh_isstate(SH_ERREXIT));
}
if(monitor)
sh_onstate(SH_MONITOR);
close(pv[1-fd]);
sh_iosave(-pv[fd], sh.topfd);
}
else
#endif /* SHOPT_DEVFD */
if(!(argp->argflag&ARG_RAW))
count = sh_macexpand(argp,argchain);
else
{
argp->argchn.ap = *argchain;
*argchain = argp;
argp->argflag |= ARG_MAKE;
count++;
}
return(count);
}

View File

@@ -0,0 +1,195 @@
/* $XConsortium: arith.c /main/3 1995/11/01 16:45:38 rswiston $ */
/***************************************************************
* *
* AT&T - PROPRIETARY *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF *
* AT&T BELL LABORATORIES *
* AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN *
* ACCORDANCE WITH APPLICABLE AGREEMENTS *
* *
* Copyright (c) 1995 AT&T Corp. *
* Unpublished & Not for Publication *
* All Rights Reserved *
* *
* The copyright notice above does not evidence any *
* actual or intended publication of such source code *
* *
* This software was created by the *
* Advanced Software Technology Department *
* AT&T Bell Laboratories *
* *
* For further information contact *
* {research,attmail}!dgk *
* *
***************************************************************/
/* : : generated by proto : : */
#if !defined(__PROTO__)
#if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus)
#if defined(__cplusplus)
#define __MANGLE__ "C"
#else
#define __MANGLE__
#endif
#define __STDARG__
#define __PROTO__(x) x
#define __OTORP__(x)
#define __PARAM__(n,o) n
#if !defined(__STDC__) && !defined(__cplusplus)
#if !defined(c_plusplus)
#define const
#endif
#define signed
#define void int
#define volatile
#define __V_ char
#else
#define __V_ void
#endif
#else
#define __PROTO__(x) ()
#define __OTORP__(x) x
#define __PARAM__(n,o) o
#define __MANGLE__
#define __V_ char
#define const
#define signed
#define void int
#define volatile
#endif
#if defined(__cplusplus) || defined(c_plusplus)
#define __VARARG__ ...
#else
#define __VARARG__
#endif
#if defined(__STDARG__)
#define __VA_START__(p,a) va_start(p,a)
#else
#define __VA_START__(p,a) va_start(p)
#endif
#endif
#include "defs.h"
#include <ctype.h>
#include "lexstates.h"
#include "name.h"
#include "streval.h"
#include "FEATURE/locale"
static int level;
static double arith __PARAM__((const char **ptr, struct lval *lvalue, int type, double n), (ptr, lvalue, type, n)) __OTORP__(const char **ptr; struct lval *lvalue; int type; double n;){
register double r= 0;
char *str = (char*)*ptr;
switch(type)
{
case ASSIGN:
{
register Namval_t *np = (Namval_t*)(lvalue->value);
register Namarr_t *ap;
if(ap = nv_arrayptr(np))
{
if(!array_assoc(ap))
nv_putsub(np, NIL(char*),lvalue->flag);
}
nv_putval(np, (char*)&n, NV_INTEGER);
break;
}
case LOOKUP:
{
register int c = *str;
lvalue->value = (char*)0;
if(c=='.')
c = str[1];
if(isaletter(c))
{
register Namval_t *np;
while(c= *++str, isaname(c)||c=='.');
if(c=='(')
{
int fsize = str- (char*)(*ptr);
const struct mathtab *tp;
c = **ptr;
lvalue->fun = 0;
for(tp=shtab_math; *tp->fname; tp++)
{
if(*tp->fname > c)
break;
if(*tp->fname==c && strncmp(tp->fname,*ptr,fsize)==0 && (fsize==4 || tp->fname[fsize]==0))
{
lvalue->fun = tp->fnptr;
break;
}
}
if(lvalue->fun)
break;
lvalue->value = (char*)e_function;
return(r);
}
*str = 0;
np = nv_open(*ptr,sh.var_tree,NV_NOASSIGN|NV_VARNAME);
*str = c;
if(nv_isattr(np,NV_INTEGER|NV_DOUBLE)==(NV_INTEGER|NV_DOUBLE))
lvalue->isfloat=1;
if(c=='[')
str = nv_endsubscript(np,str,NV_ADD);
else if(nv_isattr(np,NV_ARRAY))
nv_putsub(np,NIL(char*),ARRAY_UNDEF);
lvalue->value = (char*)np;
lvalue->flag = nv_aindex(np);
}
else
{
char *val = str;
sh.lastbase = 1;
r = strton(val,&str, &sh.lastbase,-1);
if(sh.lastbase<=1)
sh.lastbase=10;
if((c= *str)==GETDECIMAL(0) || c=='e' || c == 'E')
{
lvalue->isfloat=1;
r = strtod(val,&str);
}
}
break;
}
case VALUE:
{
register Namval_t *np = (Namval_t*)(lvalue->value);
if(sh_isoption(SH_NOEXEC))
return(0);
if((level || sh_isoption(SH_NOUNSET)) && nv_isnull(np) && !nv_isattr(np,NV_INTEGER))
{
*ptr = nv_name(np);
lvalue->value = (char*)e_notset+4;
return(0);
}
level++;
r = nv_getnum(np);
level--;
return(r);
}
case ERRMSG:
level=0;
error(ERROR_exit(1),lvalue->value,*ptr);
}
*ptr = str;
return(r);
}
double sh_strnum __PARAM__((register const char *str, char** ptr), (str, ptr)) __OTORP__(register const char *str; char** ptr;){
return(strval(str,(char**)ptr, arith));
}
double sh_arith __PARAM__((register const char *str), (str)) __OTORP__(register const char *str;){
const char *ptr = str;
register double d;
if(*str==0)
return(0);
d = strval(str,(char**)&ptr,arith);
if(*ptr)
error(ERROR_exit(1),e_lexbadchar,*ptr,str);
return(d);
}

Some files were not shown because too many files have changed in this diff Show More