summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshell/common/shell.3
diff options
context:
space:
mode:
authorApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
committerApril Chin <April.Chin@Sun.COM>2008-12-27 14:59:38 -0800
commit7c2fbfb345896881c631598ee3852ce9ce33fb07 (patch)
tree4b173b5657508562dfc0aa05f7d056d1e9add505 /usr/src/lib/libshell/common/shell.3
parent6071ac1de68fed78e1e10052045bbb5f1732a263 (diff)
downloadillumos-joyent-7c2fbfb345896881c631598ee3852ce9ce33fb07.tar.gz
PSARC/2008/094 ksh93 Update 1
PSARC/2008/344 ksh93 Integration Update 1 Amendments 1 PSARC/2008/589 Remove /usr/bin/printf from PSARC case 2008 094 6619428 *ksh93* RFE: Update ksh93 in Solaris to ast-ksh.2008-11-04 6788659 RFE: Update libpp in Solaris to ast-open.2008-07-25 6561901 RFE: Add "shcomp" (shell script compiler) + kernel module to exec binary sh code 6599668 RFE: Move consumers of alias.sh over to ksh93 6595183 *ksh93* RFE: Update ksh93-integration demo code 6775901 *ksh93* no C message catalogs are generated for ksh93 6451262 *sleep* RFE: /usr/bin/sleep should support floating-point values 6687139 *ksh93* command substitution, exec, and stdout redirection cause allocation loop 6703761 *ksh93* crashes in script containing uncommon output redirections 6715496 *ksh93* SEGVs on array reinitialization 6713682 *ksh93* Creating a compound variable in a subshell "bleeds through" to the calling subshell 6672350 *ksh93* causes parent shell to die when child shell is suspended 6745015 *ksh93* VARIABLE=`command substitution` assignment is not reliable on OpenSolaris 6710205 *ksh93* problem with command substitution (within back quotes) containing \$' 6737600 *ksh93* exits debugger when user presses ctrl-c 6748645 *ksh93* fc -l -e - is mis-parsed, outputs wrong error message "-e - requires single argument" 6754020 *ksh93* does weird '[' expansion 6753538 *ksh93* umask modification leaks out of a ksh93 subshell 6766246 *ksh93* bug in pattern matching 6763594 *ksh93* executes command after "command" builtin twice on failure 6762665 *ksh93* Difficult-to-reproduce SIGSEGV in ksh93
Diffstat (limited to 'usr/src/lib/libshell/common/shell.3')
-rw-r--r--usr/src/lib/libshell/common/shell.326
1 files changed, 20 insertions, 6 deletions
diff --git a/usr/src/lib/libshell/common/shell.3 b/usr/src/lib/libshell/common/shell.3
index e6fbbf026e..7d7394bbc4 100644
--- a/usr/src/lib/libshell/common/shell.3
+++ b/usr/src/lib/libshell/common/shell.3
@@ -20,6 +20,7 @@ libshell.a -lshell
Shell_t;
Shopt_t;
Shscope_t;
+Shbltin_t;
Shbltin_f;
Shinit_f;
Shwait_f;
@@ -29,7 +30,7 @@ Shwait_f;
.nf
.ft 5
int sh_main(int \fIargc\fP, char *\fIargv\fP[], Sh_init \fIfn\fP);
-Shell_t *sh_init(int \fIargc\fP, char *\fIargv\fP);
+Shell_t *sh_init(int \fIargc\fP, char *\fIargv\fP[]);
Shell_t *sh_getinterp(void);
Namval_t *sh_addbuiltin(const char *\fIname\fP,Sh_bltin_f \fIfn\fP,void *\fIarg\fP);
@@ -40,6 +41,7 @@ unsigned int sh_offoption(int \fIoption\fP);
void *sh_parse(Shell_t *\fIshp\fP, Sfio_t *\fIsp\fP, int \fIflags\fP);
int sh_trap(const char *\fIstring\fP, int \fImode\fP);
+int sh_run(int \fIargc\fP, char *\fIargv\fP[]);
int sh_eval(Sfio_t *\fIsp\fP,int \fImode\fP);
int sh_fun(Namval_t *\fIfunnode\fP, Namval_t *\fIvarnode\fP, char *\fIargv\fP[]);
int sh_funscope(int \fIargc\fP,char *\fIargv\fP[],int(*\fIfn\fP)(void*),void *\fIarg\fP,int \fIflags\fP);
@@ -103,7 +105,10 @@ into the shell by loading dynamic libraries
at run time using the \f5builtin\fP(1) command.
In this case the shell will look for a function named \f5lib_init\fP
in your library and, if found, will execute this function with
-argument \f50\fP when the library is loaded.
+two arguments. The first
+argument will be an \f5int\P with value \f50\fP when the library is loaded.
+The second argument will contain a pointer to a structure of type
+\f5Shbltin_t\fP.
In addition, for each argument named on the \f5builtin\fP
command line, it will look for a function named \f5b_\fP\fIname\fP\f5()\fP
in your library and will \fIname\fP as a built-in.
@@ -157,17 +162,20 @@ All built-in commands to the shell are invoked with
three arguments. The first two arguments give the
number of arguments and the argument list
and uses the same conventions as the \f5main()\fP function
-of a program. The third argument is a pointer that
+of a program. The third argument is a pointer to a structure
+of type \f5Shbltin_t\fP. This structure contains \f5shp\P which is a pointer
+to the shell interpreter, and \f5ptr\fP which is a pointer that
can be associated with each built-in.
The \f5sh_addbuiltin()\fP function is used to add, replace or delete
built-in commands.
It takes the name of the built-in, \fIname\fP, a pointer
to the function that implements the built-in, \fIfn\fP, and
-a pointer that will be passed to the function when
+a pointer that will be passed to the function in the \f5ptr\fP field when
it is invoked.
If, \fIfn\fP is non-\f5NULL\fP the built-in command
-is added or replaced. Otherwise, the given
-built-in command will be deleted.
+is added or replaced. Otherwise, \f5sh_addbuiltin()\fP will
+return a pointer to the built-in if it exists or \f5NULL\fP otherwise.
+If \fIarg\fP is \f5(void*)1\fP the built-in will be deleted.
The \fIname\fP argument can be in the format of a pathname.
It cannot be the name of any of the special built-in commands.
If \fIname\fP contains a \f5/\fP, the built-in is the basename of
@@ -268,6 +276,12 @@ is compiled and then executed so that aliases defined
within the string or file will not take effect until
the next command is executed.
.PP
+The \f5sh_run()\fP function will run the command given by
+by the argument list \fIargv\fP containing \fIargc\fP elements.
+If \fIargv\fP\f5[0]\fP does not contain a \f5/\fP, it will
+be checked to see if it is a built-in or function before
+performing a path search.
+.PP
The \f5sh_eval()\fP function executes a string or file
stream \fIsp\fP.
If \fImode\fP is non-zero and the history file has