summaryrefslogtreecommitdiff
path: root/src/cmd/ksh93/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/ksh93/include')
-rw-r--r--src/cmd/ksh93/include/argnod.h145
-rw-r--r--src/cmd/ksh93/include/builtins.h202
-rw-r--r--src/cmd/ksh93/include/defs.h509
-rw-r--r--src/cmd/ksh93/include/edit.h286
-rw-r--r--src/cmd/ksh93/include/env.h50
-rw-r--r--src/cmd/ksh93/include/fault.h127
-rw-r--r--src/cmd/ksh93/include/fcin.h71
-rw-r--r--src/cmd/ksh93/include/history.h75
-rw-r--r--src/cmd/ksh93/include/io.h126
-rw-r--r--src/cmd/ksh93/include/jobs.h216
-rw-r--r--src/cmd/ksh93/include/lexstates.h157
-rw-r--r--src/cmd/ksh93/include/name.h268
-rw-r--r--src/cmd/ksh93/include/national.h37
-rw-r--r--src/cmd/ksh93/include/nval.h311
-rw-r--r--src/cmd/ksh93/include/path.h147
-rw-r--r--src/cmd/ksh93/include/regress.h66
-rw-r--r--src/cmd/ksh93/include/shell.h259
-rw-r--r--src/cmd/ksh93/include/shlex.h171
-rw-r--r--src/cmd/ksh93/include/shnodes.h221
-rw-r--r--src/cmd/ksh93/include/shtable.h65
-rw-r--r--src/cmd/ksh93/include/streval.h207
-rw-r--r--src/cmd/ksh93/include/terminal.h195
-rw-r--r--src/cmd/ksh93/include/test.h72
-rw-r--r--src/cmd/ksh93/include/timeout.h30
-rw-r--r--src/cmd/ksh93/include/ulimit.h174
-rw-r--r--src/cmd/ksh93/include/variables.h111
-rw-r--r--src/cmd/ksh93/include/version.h20
27 files changed, 4318 insertions, 0 deletions
diff --git a/src/cmd/ksh93/include/argnod.h b/src/cmd/ksh93/include/argnod.h
new file mode 100644
index 0000000..2ed7302
--- /dev/null
+++ b/src/cmd/ksh93/include/argnod.h
@@ -0,0 +1,145 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef ARG_RAW
+/*
+ * 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;
+ char *iovname;
+};
+
+struct comnod
+{
+ int comtyp;
+ struct ionod *comio;
+ struct argnod *comarg;
+ struct argnod *comset;
+ void *comnamp;
+ void *comnamq;
+ void *comstate;
+ int comline;
+};
+
+#define COMBITS 4
+#define COMMSK ((1<<COMBITS)-1)
+#define COMSCAN (01<<COMBITS)
+#define COMFIXED (02<<COMBITS)
+
+struct slnod /* struct for link list of stacks */
+{
+ struct slnod *slnext;
+ struct slnod *slchild;
+ Stak_t *slptr;
+ /* slpad aligns struct functnod = struct slnod + 1 on some architectures */
+ struct slnod *slpad;
+};
+
+/*
+ * This struct is use to hold $* lists and arrays
+ */
+
+struct dolnod
+{
+ int dolrefcnt; /* reference count */
+ int dolmax; /* size of dolval array */
+ int dolnum; /* number of elements */
+ int 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;
+ char *cp;
+ int len;
+ } argchn;
+ unsigned char argflag;
+ char argval[4];
+};
+
+
+
+/* The following should evaluate to the offset of argval in argnod */
+#define ARGVAL offsetof(struct argnod,argval[0])
+#define sh_argstr(ap) ((ap)->argflag&ARG_RAW?sh_fmtq((ap)->argval):(ap)->argval)
+#define ARG_SPARE 1
+
+
+/* legal argument flags */
+#define ARG_RAW 0x1 /* string needs no processing */
+#define ARG_MAKE 0x2 /* bit set during argument expansion */
+#define ARG_COMSUB 0x2 /* command sub */
+#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 */
+/* The following can be passed as options to sh_macexpand() */
+#define ARG_ARITH 0x100 /* arithmetic expansion */
+#define ARG_OPTIMIZE 0x200 /* try to optimize */
+#define ARG_NOGLOB 0x400 /* no file name expansion */
+#define ARG_LET 0x800 /* processing let command arguments */
+#define ARG_ARRAYOK 0x1000 /* $x[sub] ==> ${x[sub]} */
+
+extern struct dolnod *sh_argcreate(char*[]);
+extern char *sh_argdolminus(void*);
+extern int sh_argopts(int,char*[],void*);
+
+
+extern const char e_heading[];
+extern const char e_off[];
+extern const char e_on[];
+extern const char e_sptbnl[];
+extern const char e_subst[];
+extern const char e_option[];
+extern const char e_exec[];
+extern const char e_devfdNN[];
+extern const char e_devfdstd[];
+
+#endif /* ARG_RAW */
diff --git a/src/cmd/ksh93/include/builtins.h b/src/cmd/ksh93/include/builtins.h
new file mode 100644
index 0000000..b9b4233
--- /dev/null
+++ b/src/cmd/ksh93/include/builtins.h
@@ -0,0 +1,202 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef SYSDECLARE
+
+#include <option.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+#include "shtable.h"
+
+#define SYSLOGIN (shgd->bltin_cmds)
+#define SYSEXEC (shgd->bltin_cmds+1)
+#define SYSSET (shgd->bltin_cmds+2)
+#define SYSTRUE (shgd->bltin_cmds+4)
+#define SYSCOMMAND (shgd->bltin_cmds+5)
+#define SYSCD (shgd->bltin_cmds+6)
+#define SYSBREAK (shgd->bltin_cmds+7)
+#define SYSCONT (shgd->bltin_cmds+8)
+#define SYSTYPESET (shgd->bltin_cmds+9)
+#define SYSTEST (shgd->bltin_cmds+10)
+#define SYSBRACKET (shgd->bltin_cmds+11)
+#define SYSLET (shgd->bltin_cmds+12)
+#define SYSEXPORT (shgd->bltin_cmds+13)
+#define SYSDOT (shgd->bltin_cmds+14)
+#define SYSRETURN (shgd->bltin_cmds+15)
+#if SHOPT_BASH
+# define SYSLOCAL (shgd->bltin_cmds+16)
+#else
+# define SYSLOCAL 0
+#endif
+
+/* entry point for shell special builtins */
+
+#if _BLD_shell && defined(__EXPORT__)
+# define extern __EXPORT__
+#endif
+
+extern int b_alias(int, char*[],Shbltin_t*);
+extern int b_break(int, char*[],Shbltin_t*);
+extern int b_dot_cmd(int, char*[],Shbltin_t*);
+extern int b_enum(int, char*[],Shbltin_t*);
+extern int b_exec(int, char*[],Shbltin_t*);
+extern int b_eval(int, char*[],Shbltin_t*);
+extern int b_return(int, char*[],Shbltin_t*);
+extern int B_login(int, char*[],Shbltin_t*);
+extern int b_true(int, char*[],Shbltin_t*);
+extern int b_false(int, char*[],Shbltin_t*);
+extern int b_readonly(int, char*[],Shbltin_t*);
+extern int b_set(int, char*[],Shbltin_t*);
+extern int b_shift(int, char*[],Shbltin_t*);
+extern int b_trap(int, char*[],Shbltin_t*);
+extern int b_typeset(int, char*[],Shbltin_t*);
+extern int b_unset(int, char*[],Shbltin_t*);
+extern int b_unalias(int, char*[],Shbltin_t*);
+
+/* The following are for job control */
+#if defined(SIGCLD) || defined(SIGCHLD)
+ extern int b_jobs(int, char*[],Shbltin_t*);
+ extern int b_kill(int, char*[],Shbltin_t*);
+# ifdef SIGTSTP
+ extern int b_bg(int, char*[],Shbltin_t*);
+# endif /* SIGTSTP */
+#endif
+
+/* The following utilities are built-in because of side-effects */
+extern int b_builtin(int, char*[],Shbltin_t*);
+extern int b_cd(int, char*[],Shbltin_t*);
+extern int b_command(int, char*[],Shbltin_t*);
+extern int b_getopts(int, char*[],Shbltin_t*);
+extern int b_hist(int, char*[],Shbltin_t*);
+extern int b_let(int, char*[],Shbltin_t*);
+extern int b_read(int, char*[],Shbltin_t*);
+extern int b_ulimit(int, char*[],Shbltin_t*);
+extern int b_umask(int, char*[],Shbltin_t*);
+#ifdef _cmd_universe
+ extern int b_universe(int, char*[],Shbltin_t*);
+#endif /* _cmd_universe */
+#if SHOPT_FS_3D
+ extern int b_vpath(int, char*[],Shbltin_t*);
+#endif /* SHOPT_FS_3D */
+extern int b_wait(int, char*[],Shbltin_t*);
+extern int b_whence(int, char*[],Shbltin_t*);
+
+extern int b_alarm(int, char*[],Shbltin_t*);
+extern int b_print(int, char*[],Shbltin_t*);
+extern int b_printf(int, char*[],Shbltin_t*);
+extern int b_pwd(int, char*[],Shbltin_t*);
+extern int b_sleep(int, char*[],Shbltin_t*);
+extern int b_test(int, char*[],Shbltin_t*);
+#if !SHOPT_ECHOPRINT
+ extern int B_echo(int, char*[],Shbltin_t*);
+#endif /* SHOPT_ECHOPRINT */
+
+#undef extern
+
+extern const char e_alrm1[];
+extern const char e_alrm2[];
+extern const char e_badfun[];
+extern const char e_baddisc[];
+extern const char e_nofork[];
+extern const char e_nosignal[];
+extern const char e_nolabels[];
+extern const char e_notimp[];
+extern const char e_nosupport[];
+extern const char e_badbase[];
+extern const char e_overlimit[];
+
+extern const char e_eneedsarg[];
+extern const char e_oneoperand[];
+extern const char e_toodeep[];
+extern const char e_badname[];
+extern const char e_badsyntax[];
+#ifdef _cmd_universe
+ extern const char e_nouniverse[];
+#endif /* _cmd_universe */
+extern const char e_histopen[];
+extern const char e_condition[];
+extern const char e_badrange[];
+extern const char e_trap[];
+extern const char e_direct[];
+extern const char e_defedit[];
+extern const char e_cneedsarg[];
+extern const char e_defined[];
+#if SHOPT_FS_3D
+ extern const char e_cantset[];
+ extern const char e_cantget[];
+ extern const char e_mapping[];
+ extern const char e_versions[];
+#endif /* SHOPT_FS_3D */
+
+/* for option parsing */
+extern const char sh_set[];
+extern const char sh_optalarm[];
+extern const char sh_optalias[];
+extern const char sh_optbreak[];
+extern const char sh_optbuiltin[];
+extern const char sh_optcd[];
+extern const char sh_optcommand[];
+extern const char sh_optcont[];
+extern const char sh_optdot[];
+#ifndef ECHOPRINT
+ extern const char sh_optecho[];
+#endif /* !ECHOPRINT */
+extern const char sh_opteval[];
+extern const char sh_optexec[];
+extern const char sh_optexit[];
+extern const char sh_optexport[];
+extern const char sh_optgetopts[];
+extern const char sh_optbg[];
+extern const char sh_optdisown[];
+extern const char sh_optfg[];
+extern const char sh_opthist[];
+extern const char sh_optjobs[];
+extern const char sh_optkill[];
+extern const char sh_optksh[];
+extern const char sh_optlet[];
+extern const char sh_optprint[];
+extern const char sh_optprintf[];
+extern const char sh_optpwd[];
+extern const char sh_optread[];
+extern const char sh_optreadonly[];
+extern const char sh_optreturn[];
+extern const char sh_optset[];
+extern const char sh_optshift[];
+extern const char sh_optsleep[];
+extern const char sh_opttrap[];
+extern const char sh_opttypeset[];
+extern const char sh_optulimit[];
+extern const char sh_optumask[];
+extern const char sh_optunalias[];
+extern const char sh_optwait[];
+#ifdef _cmd_universe
+ extern const char sh_optuniverse[];
+#endif /* _cmd_universe */
+extern const char sh_optunset[];
+#if SHOPT_FS_3D
+ extern const char sh_optvpath[];
+ extern const char sh_optvmap[];
+#endif /* SHOPT_FS_3D */
+extern const char sh_optwhence[];
+#endif /* SYSDECLARE */
+
+extern const char e_dict[];
+
diff --git a/src/cmd/ksh93/include/defs.h b/src/cmd/ksh93/include/defs.h
new file mode 100644
index 0000000..dd80552
--- /dev/null
+++ b/src/cmd/ksh93/include/defs.h
@@ -0,0 +1,509 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Shell interface private definitions
+ *
+ */
+#ifndef defs_h_defined
+#define defs_h_defined
+
+#include <ast.h>
+#include <sfio.h>
+#include <error.h>
+#include "FEATURE/externs"
+#include "FEATURE/options"
+#include <cdt.h>
+#include <history.h>
+#include "fault.h"
+#include "argnod.h"
+#include "name.h"
+#include <ctype.h>
+
+#ifndef pointerof
+#define pointerof(x) ((void*)((char*)0+(x)))
+#endif
+
+#define Empty ((char*)(e_sptbnl+3))
+
+#define env_change() (++ast.env_serial)
+#if SHOPT_ENV
+# include <env.h>
+#else
+# define Env_t void
+# define sh_envput(e,p) env_change()
+# define env_delete(e,p) env_change()
+#endif
+
+extern char* sh_getenv(const char*);
+extern char* sh_setenviron(const char*);
+
+/*
+ * note that the first few fields have to be the same as for
+ * Shscoped_t in <shell.h>
+ */
+
+
+struct sh_scoped
+{
+ struct sh_scoped *prevst; /* pointer to previous state */
+ int dolc;
+ char **dolv;
+ char *cmdname;
+ char *filename;
+ char *funname;
+ int lineno;
+ Dt_t *save_tree; /* var_tree for calling function */
+ struct sh_scoped *self; /* pointer to copy of this scope*/
+ Dt_t *var_local; /* local level variables for name() */
+ struct slnod *staklist; /* link list of function stacks */
+ int states;
+ int breakcnt;
+ int execbrk;
+ int loopcnt;
+ int firstline;
+ int32_t optindex;
+ int32_t optnum;
+ int32_t tmout; /* value for TMOUT */
+ short optchar;
+ short opterror;
+ int ioset;
+ unsigned short trapmax;
+ char *trap[SH_DEBUGTRAP+1];
+ char **trapcom;
+ char **otrapcom;
+ void *timetrap;
+ struct Ufunction *real_fun; /* current 'function name' function */
+};
+
+struct limits
+{
+ long arg_max; /* max arg+env exec() size */
+ 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 */
+};
+
+#ifndef SH_wait_f_defined
+ typedef int (*Shwait_f)(int, long, int);
+# define SH_wait_f_defined
+#endif
+
+
+struct shared
+{
+ struct limits lim;
+ uid_t userid;
+ uid_t euserid;
+ gid_t groupid;
+ gid_t egroupid;
+ pid_t pid;
+ int32_t ppid;
+ unsigned char sigruntime[2];
+ Namval_t *bltin_nodes;
+ Namval_t *bltin_cmds;
+ History_t *hist_ptr;
+ char *shpath;
+ char *user;
+ char **sigmsg;
+ char *rcfile;
+ char **login_files;
+ void *ed_context;
+ void *init_context;
+ void *job_context;
+ int *stats;
+ int bltin_nnodes; /* number of bltins nodes */
+ int sigmax;
+ int nforks;
+ Shwait_f waitevent;
+};
+
+#define _SH_PRIVATE \
+ struct shared *gd; /* global data */ \
+ struct sh_scoped st; /* scoped information */ \
+ Stk_t *stk; /* stack poiter */ \
+ Sfio_t *heredocs; /* current here-doc temp file */ \
+ Sfio_t *funlog; /* for logging function definitions */ \
+ int **fdptrs; /* pointer to file numbers */ \
+ int savexit; \
+ char *lastarg; \
+ char *lastpath; /* last alsolute path found */ \
+ int path_err; /* last error on path search */ \
+ Dt_t *track_tree; /* for tracked aliases*/ \
+ Dt_t *var_base; /* global level variables */ \
+ Namval_t *namespace; /* current active namespace*/ \
+ Namval_t *last_table; /* last table used in last nv_open */ \
+ Namval_t *prev_table; /* previous table used in nv_open */ \
+ Sfio_t *outpool; /* ouput stream pool */ \
+ long timeout; /* read timeout */ \
+ short curenv; /* current subshell number */ \
+ short jobenv; /* subshell number for jobs */ \
+ int infd; /* input file descriptor */ \
+ short nextprompt; /* next prompt is PS<nextprompt> */ \
+ short poolfiles; \
+ Namval_t *posix_fun; /* points to last name() function */ \
+ 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 *fifo; /* fifo name for process sub */ \
+ int oldexit; \
+ pid_t bckpid; /* background process id */ \
+ pid_t cpid; \
+ pid_t spid; /* subshell process id */ \
+ pid_t pipepid; \
+ pid_t outpipepid; \
+ int topfd; \
+ int savesig; \
+ unsigned char *sigflag; /* pointer to signal states */ \
+ char openmatch; \
+ char intrap; \
+ char login_sh; \
+ char lastbase; \
+ char forked; \
+ char binscript; \
+ char deftype; \
+ char funload; \
+ char used_pos; /* used postional parameter */\
+ char universe; \
+ char winch; \
+ char inarith; /* set when in ((...)) */ \
+ char indebug; /* set when in debug trap */ \
+ unsigned char ignsig; /* ignored signal in subshell */ \
+ unsigned char lastsig; /* last signal received */ \
+ char pathinit; /* pathinit called from subshell */ \
+ char comsub; /* set when in $() comsub */ \
+ char subshare; /* set when in ${..} comsub */ \
+ char toomany; /* set when out of fd's */ \
+ char instance; /* in set_instance */ \
+ char decomma; /* decimal_point=',' */ \
+ char redir0; /* redirect of 0 */ \
+ char *readscript; /* set before reading a script */ \
+ int subdup; /* bitmask for dups of 1 */ \
+ int *inpipe; /* input pipe pointer */ \
+ int *outpipe; /* output pipe pointer */ \
+ int cpipe[3]; \
+ int coutpipe; \
+ int inuse_bits; \
+ struct argnod *envlist; \
+ struct dolnod *arglist; \
+ int fn_depth; \
+ int fn_reset; \
+ int dot_depth; \
+ int hist_depth; \
+ int xargmin; \
+ int xargmax; \
+ int xargexit; \
+ int nenv; \
+ mode_t mask; \
+ Env_t *env; \
+ void *init_context; \
+ void *mac_context; \
+ void *lex_context; \
+ void *arg_context; \
+ void *job_context; \
+ void *pathlist; \
+ void *defpathlist; \
+ void *cdpathlist; \
+ char **argaddr; \
+ void *optlist; \
+ struct sh_scoped global; \
+ struct checkpt checkbase; \
+ Shinit_f userinit; \
+ Shbltin_f bltinfun; \
+ Shbltin_t bltindata; \
+ char *cur_line; \
+ int offsets[10]; \
+ Sfio_t **sftable; \
+ unsigned char *fdstatus; \
+ const char *pwd; \
+ void *jmpbuffer; \
+ void *mktype; \
+ Sfio_t *strbuf; \
+ Sfio_t *strbuf2; \
+ Dt_t *first_root; \
+ Dt_t *prefix_root; \
+ Dt_t *last_root; \
+ Dt_t *prev_root; \
+ Dt_t *fpathdict; \
+ Dt_t *typedict; \
+ Dt_t *inpool; \
+ Dt_t *transdict; \
+ char ifstable[256]; \
+ unsigned long test; \
+ Shopt_t offoptions; \
+ Shopt_t glob_options; \
+ Namval_t *typeinit; \
+ Namfun_t nvfun; \
+ char *mathnodes; \
+ void *coshell; \
+ struct Regress_s*regress;
+
+#include <shell.h>
+
+#include "shtable.h"
+#include "regress.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)
+
+#ifndef SH_DICT
+#define SH_DICT (void*)e_dict
+#endif
+
+#ifndef SH_CMDLIB_DIR
+#define SH_CMDLIB_DIR "/opt/ast/bin"
+#endif
+
+/* states */
+/* low numbered states are same as options */
+#define SH_NOFORK 0 /* set when fork not necessary */
+#define SH_FORKED 7 /* set when process has been forked */
+#define SH_PROFILE 8 /* set when processing profiles */
+#define SH_NOALIAS 9 /* do not expand non-exported aliases */
+#define SH_NOTRACK 10 /* set to disable sftrack() function */
+#define SH_STOPOK 11 /* set for stopable builtins */
+#define SH_GRACE 12 /* set for timeout grace period */
+#define SH_TIMING 13 /* set while timing pipelines */
+#define SH_DEFPATH 14 /* set when using default path */
+#define SH_INIT 15 /* set when initializing the shell */
+#define SH_TTYWAIT 16 /* waiting for keyboard input */
+#define SH_FCOMPLETE 17 /* set for filename completion */
+#define SH_PREINIT 18 /* set with SH_INIT before parsing options */
+#define SH_COMPLETE 19 /* set for command completion */
+
+#define SH_BASH 41
+#define SH_BRACEEXPAND 42
+#define SH_POSIX 46
+#define SH_MULTILINE 47
+
+#define SH_NOPROFILE 78
+#define SH_NOUSRPROFILE 79
+#define SH_LOGIN_SHELL 67
+#define SH_COMMANDLINE 0x100
+#define SH_BASHEXTRA 0x200
+#define SH_BASHOPT 0x400
+
+#define SH_ID "ksh" /* ksh id */
+#define SH_STD "sh" /* standard sh id */
+
+/* defines for sh_type() */
+
+#define SH_TYPE_SH 001
+#define SH_TYPE_KSH 002
+#define SH_TYPE_BASH 004
+#define SH_TYPE_LOGIN 010
+#define SH_TYPE_PROFILE 020
+#define SH_TYPE_RESTRICTED 040
+
+#if SHOPT_BASH
+# ifndef SHOPT_HISTEXPAND
+# define SHOPT_HISTEXPAND 1
+# endif
+/*
+ * define for all the bash options
+ */
+# define SH_CDABLE_VARS 51
+# define SH_CDSPELL 52
+# define SH_CHECKHASH 53
+# define SH_CHECKWINSIZE 54
+# define SH_CMDHIST 55
+# define SH_DOTGLOB 56
+# define SH_EXECFAIL 57
+# define SH_EXPAND_ALIASES 58
+# define SH_EXTGLOB 59
+# define SH_HOSTCOMPLETE 63
+# define SH_HUPONEXIT 64
+# define SH_INTERACTIVE_COMM 65
+# define SH_LITHIST 66
+# define SH_MAILWARN 68
+# define SH_NOEMPTYCMDCOMPL 69
+# define SH_NOCASEGLOB 70
+# define SH_NULLGLOB 71
+# define SH_PHYSICAL 45
+# define SH_PROGCOMP 72
+# define SH_PROMPTVARS 73
+# define SH_RESTRICTED2 74
+# define SH_SHIFT_VERBOSE 75
+# define SH_SOURCEPATH 76
+# define SH_XPG_ECHO 77
+#endif
+
+#if SHOPT_HISTEXPAND
+# define SH_HISTAPPEND 60
+# define SH_HISTEXPAND 43
+# define SH_HISTORY2 44
+# define SH_HISTREEDIT 61
+# define SH_HISTVERIFY 62
+#endif
+
+#ifndef PIPE_BUF
+# define PIPE_BUF 512
+#endif
+
+#if SHOPT_PFSH && ( !_lib_getexecuser || !_lib_free_execattr )
+# undef SHOPT_PFSH
+#endif
+
+#define MATCH_MAX 64
+
+#define SH_READEVAL 0x4000 /* for sh_eval */
+#define SH_FUNEVAL 0x10000 /* for sh_eval for function load */
+
+extern struct shared *shgd;
+extern Shell_t *nv_shell(Namval_t*);
+extern int sh_addlib(Shell_t*,void*);
+extern void sh_applyopts(Shell_t*,Shopt_t);
+extern char **sh_argbuild(Shell_t*,int*,const struct comnod*,int);
+extern struct dolnod *sh_argfree(Shell_t *, struct dolnod*,int);
+extern struct dolnod *sh_argnew(Shell_t*,char*[],struct dolnod**);
+extern void *sh_argopen(Shell_t*);
+extern struct argnod *sh_argprocsub(Shell_t*,struct argnod*);
+extern void sh_argreset(Shell_t*,struct dolnod*,struct dolnod*);
+extern Namval_t *sh_assignok(Namval_t*,int);
+extern struct dolnod *sh_arguse(Shell_t*);
+extern char *sh_checkid(char*,char*);
+extern void sh_chktrap(Shell_t*);
+extern void sh_deparse(Sfio_t*,const Shnode_t*,int);
+extern int sh_debug(Shell_t *shp,const char*,const char*,const char*,char *const[],int);
+extern int sh_echolist(Shell_t*,Sfio_t*, int, char**);
+extern struct argnod *sh_endword(Shell_t*,int);
+extern char **sh_envgen(void);
+#if SHOPT_ENV
+extern void sh_envput(Env_t*, Namval_t*);
+#endif
+extern void sh_envnolocal(Namval_t*,void*);
+extern Sfdouble_t sh_arith(Shell_t*,const char*);
+extern void *sh_arithcomp(Shell_t *,char*);
+extern pid_t sh_fork(Shell_t*,int,int*);
+extern pid_t _sh_fork(Shell_t*,pid_t, int ,int*);
+extern char *sh_mactrim(Shell_t*,char*,int);
+extern int sh_macexpand(Shell_t*,struct argnod*,struct argnod**,int);
+extern int sh_macfun(Shell_t*,const char*,int);
+extern void sh_machere(Shell_t*,Sfio_t*, Sfio_t*, char*);
+extern void *sh_macopen(Shell_t*);
+extern char *sh_macpat(Shell_t*,struct argnod*,int);
+extern Sfdouble_t sh_mathfun(Shell_t*, void*, int, Sfdouble_t*);
+extern int sh_outtype(Shell_t*, Sfio_t*);
+extern char *sh_mactry(Shell_t*,char*);
+extern int sh_mathstd(const char*);
+extern void sh_printopts(Shopt_t,int,Shopt_t*);
+extern int sh_readline(Shell_t*,char**,int,int,long);
+extern Sfio_t *sh_sfeval(char*[]);
+extern void sh_setmatch(Shell_t*,const char*,int,int,int[],int);
+extern Dt_t *sh_subaliastree(int);
+extern void sh_scope(Shell_t*, struct argnod*, int);
+extern Namval_t *sh_scoped(Shell_t*, Namval_t*);
+extern Dt_t *sh_subfuntree(int);
+extern void sh_subjobcheck(pid_t);
+extern int sh_subsavefd(int);
+extern void sh_subtmpfile(Shell_t*);
+extern char *sh_substitute(const char*,const char*,char*);
+extern void sh_timetraps(Shell_t*);
+extern const char *_sh_translate(const char*);
+extern int sh_trace(Shell_t*,char*[],int);
+extern void sh_trim(char*);
+extern int sh_type(const char*);
+extern void sh_unscope(Shell_t*);
+extern void sh_utol(const char*, char*);
+extern int sh_whence(char**,int);
+#if SHOPT_COSHELL
+ extern int sh_coaddfile(Shell_t*,char*);
+ extern int sh_copipe(Shell_t*, int[], int);
+ extern int sh_coaccept(Shell_t*,int[],int);
+#endif /* SHOPT_COSHELL */
+#if SHOPT_NAMESPACE
+ extern Namval_t *sh_fsearch(Shell_t*,const char *,int);
+#endif /* SHOPT_NAMESPACE */
+
+#ifndef ERROR_dictionary
+# define ERROR_dictionary(s) (s)
+#endif
+#define sh_translate(s) _sh_translate(ERROR_dictionary(s))
+
+#define WBITS (sizeof(long)*8)
+#define WMASK (0xff)
+
+#define is_option(s,x) ((s)->v[((x)&WMASK)/WBITS] & (1L << ((x) % WBITS)))
+#define on_option(s,x) ((s)->v[((x)&WMASK)/WBITS] |= (1L << ((x) % WBITS)))
+#define off_option(s,x) ((s)->v[((x)&WMASK)/WBITS] &= ~(1L << ((x) % WBITS)))
+#define sh_isoption(x) is_option(&sh.options,x)
+#define sh_onoption(x) on_option(&sh.options,x)
+#define sh_offoption(x) off_option(&sh.options,x)
+
+
+#define sh_state(x) ( 1<<(x))
+#define sh_isstate(x) (sh.st.states&sh_state(x))
+#define sh_onstate(x) (sh.st.states |= sh_state(x))
+#define sh_offstate(x) (sh.st.states &= ~sh_state(x))
+#define sh_getstate() (sh.st.states)
+#define sh_setstate(x) (sh.st.states = (x))
+
+#define sh_sigcheck(shp) do{if(shp->trapnote&SH_SIGSET)sh_exit(SH_EXITSIG);} while(0)
+
+extern int32_t sh_mailchk;
+extern const char e_dict[];
+
+/* sh_printopts() mode flags -- set --[no]option by default */
+
+#define PRINT_VERBOSE 0x01 /* option on|off list */
+#define PRINT_ALL 0x02 /* list unset options too */
+#define PRINT_NO_HEADER 0x04 /* omit listing header */
+#define PRINT_SHOPT 0x08 /* shopt -s|-u */
+#define PRINT_TABLE 0x10 /* table of all options */
+
+#ifdef SHOPT_STATS
+ /* performance statistics */
+# define STAT_ARGHITS 0
+# define STAT_ARGEXPAND 1
+# define STAT_COMSUB 2
+# define STAT_FORKS 3
+# define STAT_FUNCT 4
+# define STAT_GLOBS 5
+# define STAT_READS 6
+# define STAT_NVHITS 7
+# define STAT_NVOPEN 8
+# define STAT_PATHS 9
+# define STAT_SVFUNCT 10
+# define STAT_SCMDS 11
+# define STAT_SPAWN 12
+# define STAT_SUBSHELL 13
+ extern const Shtable_t shtab_stats[];
+# define sh_stats(x) (shgd->stats[(x)]++)
+#else
+# define sh_stats(x)
+#endif /* SHOPT_STATS */
+
+
+#endif
diff --git a/src/cmd/ksh93/include/edit.h b/src/cmd/ksh93/include/edit.h
new file mode 100644
index 0000000..239158e
--- /dev/null
+++ b/src/cmd/ksh93/include/edit.h
@@ -0,0 +1,286 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SEARCHSIZE
+/*
+ * edit.h - common data structure for vi and emacs edit options
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#define SEARCHSIZE 80
+
+#include "FEATURE/options"
+#include "FEATURE/locale"
+#if !SHOPT_VSH && !SHOPT_ESH
+# define ed_winsize() (SEARCHSIZE)
+#else
+
+#if !KSHELL
+# include <setjmp.h>
+# include <sig.h>
+# include <ctype.h>
+#endif /* KSHELL */
+
+#include "FEATURE/setjmp"
+#include "terminal.h"
+
+#define STRIP 0377
+#define LOOKAHEAD 80
+
+#if SHOPT_MULTIBYTE
+# ifndef ESS_MAXCHAR
+# include "national.h"
+# endif /* ESS_MAXCHAR */
+ typedef wchar_t genchar;
+# define CHARSIZE (sizeof(wchar_t)<=2?3:sizeof(wchar_t))
+#else
+ typedef char genchar;
+# define CHARSIZE 1
+#endif /* SHOPT_MULTIBYTE */
+
+#define TABSIZE 8
+#define PRSIZE 160
+#define MAXLINE 1024 /* longest edit line permitted */
+
+typedef struct _edit_pos
+{
+ unsigned short line;
+ unsigned short col;
+} Edpos_t;
+
+#if SHOPT_EDPREDICT
+typedef struct Histmatch
+{
+ struct Histmatch *next;
+ int index;
+ short len;
+ short count;
+ char data[1];
+} Histmatch_t;
+#endif /* SHOPT_EDPREDICT */
+
+
+
+typedef struct edit
+{
+ sigjmp_buf e_env;
+ int e_intr;
+ int e_kill;
+ int e_erase;
+ int e_werase;
+ int e_eof;
+ int e_lnext;
+ int e_fchar;
+ int e_plen; /* length of prompt string */
+ char e_crlf; /* zero if cannot return to beginning of line */
+ char e_nocrnl; /* don't put a new-line with ^L */
+ char e_keytrap; /* set when in keytrap */
+ 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_lookahead; /* 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_tabcount;
+#ifdef _hdr_utime
+ ino_t e_tty_ino;
+ dev_t e_tty_dev;
+ char *e_tty;
+#endif
+#if SHOPT_OLDTERMIO
+ char e_echoctl;
+ char e_tcgeta;
+ struct termio e_ott;
+#endif
+#if SHOPT_MULTIBYTE
+ int e_curchar;
+ int e_cursize;
+#endif
+ int *e_globals; /* global variables */
+ genchar *e_window; /* display window image */
+ char e_inmacro; /* processing macro expansion */
+#if KSHELL
+ char e_vi_insert[2]; /* for sh_keytrap */
+ int32_t e_col; /* for sh_keytrap */
+#else
+ char e_prbuff[PRSIZE]; /* prompt buffer */
+#endif /* KSHELL */
+ struct termios e_ttyparm; /* initial tty parameters */
+ struct termios e_nttyparm; /* raw tty parameters */
+ struct termios e_savetty; /* saved terminal state */
+ int e_savefd; /* file descriptor for saved terminal state */
+ char e_macro[4]; /* macro buffer */
+ void *e_vi; /* vi specific data */
+ void *e_emacs; /* emacs specific data */
+ Shell_t *sh; /* interpreter pointer */
+ char *e_stkptr; /* saved stack pointer */
+ int e_stkoff; /* saved stack offset */
+ char **e_clist; /* completion list after <ESC>= */
+ int e_nlist; /* number of elements on completion list */
+ int e_multiline; /* allow multiple lines for editing */
+ int e_winsz; /* columns in window */
+ Edpos_t e_curpos; /* cursor line and column */
+ Namval_t *e_default; /* variable containing default value */
+ Namval_t *e_term; /* TERM variable */
+ char e_termname[80]; /* terminal name */
+#if SHOPT_EDPREDICT
+ Histmatch_t **hlist;
+ Histmatch_t *hfirst;
+ unsigned short nhlist;
+ unsigned short hoff;
+ unsigned short hmax;
+ char *hpat;
+ char *hstak;
+#endif /* SHOPT_EDPREDICT */
+} Edit_t;
+
+#undef MAXWINDOW
+#define MAXWINDOW 300 /* maximum width window */
+#define FAST 2
+#define SLOW 1
+#define ESC cntl('[')
+#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 */
+
+#if ( 'a' == 97) /* ASCII? */
+# define cntl(x) (x&037)
+#else
+# define cntl(c) (c=='D'?55:(c=='E'?45:(c=='F'?46:(c=='G'?'\a':(c=='H'?'\b': \
+ (c=='I'?'\t':(c=='J'?'\n':(c=='T'?60:(c=='U'?61:(c=='V'?50: \
+ (c=='W'?38:(c=='Z'?63:(c=='['?39:(c==']'?29: \
+ (c<'J'?c+1-'A':(c+10-'J'))))))))))))))))
+#endif
+
+#if !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 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 void ed_crlf(Edit_t*);
+extern void ed_putchar(Edit_t*, int);
+extern void ed_ringbell(void);
+extern void ed_setup(Edit_t*,int, int);
+extern void ed_flush(Edit_t*);
+extern int ed_getchar(Edit_t*,int);
+extern int ed_virt_to_phys(Edit_t*,genchar*,genchar*,int,int,int);
+extern int ed_window(void);
+extern void ed_ungetchar(Edit_t*,int);
+extern int ed_viread(void*, int, char*, int, int);
+extern int ed_read(void*, int, char*, int, int);
+extern int ed_emacsread(void*, int, char*, int, int);
+extern Edpos_t ed_curpos(Edit_t*, genchar*, int, int, Edpos_t);
+extern int ed_setcursor(Edit_t*, genchar*, int, int, int);
+#if KSHELL
+ extern int ed_macro(Edit_t*,int);
+ extern int ed_expand(Edit_t*, char[],int*,int*,int,int);
+ extern int ed_fulledit(Edit_t*);
+ extern void *ed_open(Shell_t*);
+#endif /* KSHELL */
+# if SHOPT_MULTIBYTE
+ extern int ed_internal(const char*, genchar*);
+ extern int ed_external(const genchar*, char*);
+ extern void ed_gencpy(genchar*,const genchar*);
+ extern void ed_genncpy(genchar*,const genchar*,int);
+ extern int ed_genlen(const genchar*);
+ extern int ed_setwidth(const char*);
+# endif /* SHOPT_MULTIBYTE */
+#if SHOPT_EDPREDICT
+ extern int ed_histgen(Edit_t*, const char*);
+ extern void ed_histlist(Edit_t*, int);
+#endif /* SHOPT_EDPREDICT */
+
+extern const char e_runvi[];
+#if !KSHELL
+ extern const char e_version[];
+#endif /* KSHELL */
+
+#if SHOPT_HISTEXPAND
+
+/* flags */
+
+#define HIST_EVENT 0x1 /* event designator seen */
+#define HIST_QUESTION 0x2 /* question mark event designator */
+#define HIST_HASH 0x4 /* hash event designator */
+#define HIST_WORDDSGN 0x8 /* word designator seen */
+#define HIST_QUICKSUBST 0x10 /* quick substition designator seen */
+#define HIST_SUBSTITUTE 0x20 /* for substition loop */
+#define HIST_NEWLINE 0x40 /* newline in squashed white space */
+
+/* modifier flags */
+
+#define HIST_PRINT 0x100 /* print new command */
+#define HIST_QUOTE 0x200 /* quote resulting history line */
+#define HIST_QUOTE_BR 0x400 /* quote every word on space break */
+#define HIST_GLOBALSUBST 0x800 /* apply substition globally */
+
+#define HIST_ERROR 0x1000 /* an error ocurred */
+
+/* flags to be returned */
+
+#define HIST_FLAG_RETURN_MASK (HIST_EVENT|HIST_PRINT|HIST_ERROR)
+
+extern int hist_expand(const char *, char **);
+#endif
+
+#endif
+#endif
diff --git a/src/cmd/ksh93/include/env.h b/src/cmd/ksh93/include/env.h
new file mode 100644
index 0000000..0224aa4
--- /dev/null
+++ b/src/cmd/ksh93/include/env.h
@@ -0,0 +1,50 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _ENV_H
+#define _ENV_H 1
+
+#ifdef _BLD_env
+# ifdef __EXPORT__
+# define export __EXPORT__
+# endif
+#else
+ typedef void *Env_t;
+#endif
+
+/* for use with env_open */
+#define ENV_STABLE (-1)
+
+/* for third agument to env_add */
+#define ENV_MALLOCED 1
+#define ENV_STRDUP 2
+
+extern void env_close(Env_t*);
+extern int env_add(Env_t*, const char*, int);
+extern int env_delete(Env_t*, const char*);
+extern char **env_get(Env_t*);
+extern Env_t *env_open(char**,int);
+extern Env_t *env_scope(Env_t*,int);
+
+#undef extern
+
+#endif
+
+
diff --git a/src/cmd/ksh93/include/fault.h b/src/cmd/ksh93/include/fault.h
new file mode 100644
index 0000000..e327903
--- /dev/null
+++ b/src/cmd/ksh93/include/fault.h
@@ -0,0 +1,127 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SH_SIGBITS
+/*
+ * 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"
+
+
+#ifndef SIGWINCH
+# ifdef SIGWIND
+# define SIGWINCH SIGWIND
+# else
+# ifdef SIGWINDOW
+# define SIGWINCH SIGWINDOW
+# endif
+# endif
+#endif
+
+typedef void (*SH_SIGTYPE)(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 */
+#define SH_SIGALRM 0200 /* timer alarm received */
+#define SH_SIGTERM SH_SIGOFF /* term signal received */
+#define SH_SIGRUNTIME 0400 /* runtime value */
+
+#define SH_SIGRTMIN 0 /* sh.sigruntime[] index */
+#define SH_SIGRTMAX 1 /* sh.sigruntime[] index */
+
+/*
+ * 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;
+#if (ERROR_VERSION >= 20030214L)
+ Error_context_t err;
+#else
+ struct errorcontext err;
+#endif
+};
+
+#define sh_pushcontext(shp,bp,n)( (bp)->mode=(n) , (bp)->olist=0, \
+ (bp)->topfd=shp->topfd, (bp)->prev=shp->jmplist, \
+ (bp)->err = *ERROR_CONTEXT_BASE, \
+ shp->jmplist = (sigjmp_buf*)(&(bp)->buff) \
+ )
+#define sh_popcontext(shp,bp) (shp->jmplist=(bp)->prev, errorpop(&((bp)->err)))
+
+extern void sh_fault(int);
+extern void sh_done(void*,int);
+extern void sh_sigclear(int);
+extern void sh_sigdone(void);
+extern void sh_siginit(void*);
+extern void sh_sigtrap(int);
+extern void sh_sigreset(int);
+extern void *sh_timeradd(unsigned long,int ,void (*)(void*),void*);
+extern void timerdel(void*);
+
+extern const char e_alarm[];
+
+#endif /* !SH_SIGBITS */
diff --git a/src/cmd/ksh93/include/fcin.h b/src/cmd/ksh93/include/fcin.h
new file mode 100644
index 0000000..1459a3a
--- /dev/null
+++ b/src/cmd/ksh93/include/fcin.h
@@ -0,0 +1,71 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef fcgetc
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * 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 */
+ short fclen; /* last multibyte char len */
+ void (*fcfun)(Sfio_t*,const char*,int,void*); /* advance function */
+ void *context; /* context pointer */
+ int fcleft; /* for multibyte boundary */
+ Sfoff_t fcoff; /* offset for last read */
+} Fcin_t;
+
+#if SHOPT_MULTIBYTE
+# define fcmbget(x) (mbwide()?_fcmbget(x):fcget())
+#else
+# define fcmbget(x) (fcget())
+#endif
+#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 fclast() ((char*)_Fcin.fclast)
+#define fcleft() (_Fcin.fclast-_Fcin.fcptr)
+#define fcsopen(s) (_Fcin._fcfile=(Sfio_t*)0,_Fcin.fclen=1,_Fcin.fcbuff=_Fcin.fcptr=(unsigned char*)(s))
+#define fctell() (_Fcin.fcoff + (_Fcin.fcptr-_Fcin.fcbuff))
+#define fcsave(x) (*(x) = _Fcin)
+#define fcrestore(x) (_Fcin = *(x))
+extern int fcfill(void);
+extern int fcfopen(Sfio_t*);
+extern int fcclose(void);
+void fcnotify(void(*)(Sfio_t*,const char*,int,void*),void*);
+extern int _fcmbget(short*);
+
+extern Fcin_t _Fcin; /* used by macros */
+
+#endif /* fcgetc */
diff --git a/src/cmd/ksh93/include/history.h b/src/cmd/ksh93/include/history.h
new file mode 100644
index 0000000..034a3d3
--- /dev/null
+++ b/src/cmd/ksh93/include/history.h
@@ -0,0 +1,75 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef HIST_VERSION
+/*
+ * Interface for history mechanism
+ * written by David Korn
+ *
+ */
+
+#include <ast.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 */
+ int32_t 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 const char hist_fname[];
+
+extern 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 int sh_histinit(void *);
+extern void hist_cancel(History_t*);
+extern void hist_close(History_t*);
+extern int hist_copy(char*, int, int, int);
+extern void hist_eof(History_t*);
+extern Histloc_t hist_find(History_t*,char*,int, int, int);
+extern void hist_flush(History_t*);
+extern void hist_list(History_t*,Sfio_t*, off_t, int, char*);
+extern int hist_match(History_t*,off_t, char*, int*);
+extern off_t hist_tell(History_t*,int);
+extern off_t hist_seek(History_t*,int);
+extern char *hist_word(char*, int, int);
+#if SHOPT_ESH
+ extern Histloc_t hist_locate(History_t*,int, int, int);
+#endif /* SHOPT_ESH */
+
+#endif /* HIST_VERSION */
diff --git a/src/cmd/ksh93/include/io.h b/src/cmd/ksh93/include/io.h
new file mode 100644
index 0000000..c01dd12
--- /dev/null
+++ b/src/cmd/ksh93/include/io.h
@@ -0,0 +1,126 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * UNIX shell
+ * David Korn
+ *
+ */
+
+#include <ast.h>
+#include <sfio.h>
+
+#ifndef IOBSIZE
+# define IOBSIZE SF_BUFSIZE
+#endif /* IOBSIZE */
+#define IOMAXTRY 20
+
+#ifndef SF_CLOSING
+#define SF_CLOSING SF_CLOSE
+#endif
+#ifndef SF_APPENDWR
+#define SF_APPENDWR SF_APPEND
+#endif
+
+/* 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)
+
+#define IOSUBSHELL 0x8000 /* must be larger than any file descriptor */
+
+/*
+ * The remainder of this file is only used when compiled with shell
+ */
+
+#if KSHELL
+
+#ifndef ARG_RAW
+ struct ionod;
+#endif /* !ARG_RAW */
+
+extern int sh_iocheckfd(Shell_t*,int);
+extern void sh_ioinit(Shell_t*);
+extern int sh_iomovefd(int);
+extern int sh_iorenumber(Shell_t*,int,int);
+extern void sh_pclose(int[]);
+extern void sh_iorestore(Shell_t*,int,int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+ __EXPORT__
+#endif
+extern Sfio_t *sh_iostream(Shell_t*,int);
+extern int sh_redirect(Shell_t*,struct ionod*,int);
+extern void sh_iosave(Shell_t *, int,int,char*);
+extern int sh_iovalidfd(Shell_t*, int);
+extern int sh_inuse(Shell_t*, int);
+extern void sh_iounsave(Shell_t*);
+extern int sh_chkopen(const char*);
+extern int sh_ioaccess(int,int);
+extern int sh_devtofd(const char*);
+extern int sh_isdevfd(const char*);
+extern int sh_source(Shell_t*, Sfio_t*, const char*);
+
+/* the following are readonly */
+extern const char e_pexists[];
+extern const char e_query[];
+extern const char e_history[];
+extern const char e_argtype[];
+extern const char e_create[];
+extern const char e_tmpcreate[];
+extern const char e_exists[];
+extern const char e_file[];
+extern const char e_redirect[];
+extern const char e_formspec[];
+extern const char e_badregexp[];
+extern const char e_open[];
+extern const char e_notseek[];
+extern const char e_noread[];
+extern const char e_badseek[];
+extern const char e_badwrite[];
+extern const char e_badpattern[];
+extern const char e_toomany[];
+extern const char e_pipe[];
+extern const char e_unknown[];
+extern const char e_devnull[];
+extern const char e_profile[];
+extern const char e_sysprofile[];
+#if SHOPT_SYSRC
+extern const char e_sysrc[];
+#endif
+#if SHOPT_BASH
+#if SHOPT_SYSRC
+extern const char e_bash_sysrc[];
+#endif
+extern const char e_bash_rc[];
+extern const char e_bash_login[];
+extern const char e_bash_logout[];
+extern const char e_bash_profile[];
+#endif
+extern const char e_stdprompt[];
+extern const char e_supprompt[];
+extern const char e_ambiguous[];
+#endif /* KSHELL */
diff --git a/src/cmd/ksh93/include/jobs.h b/src/cmd/ksh93/include/jobs.h
new file mode 100644
index 0000000..b67b097
--- /dev/null
+++ b/src/cmd/ksh93/include/jobs.h
@@ -0,0 +1,216 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef JOB_NFLAG
+/*
+ * 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"
+
+#if SHOPT_COSHELL
+# include <coshell.h>
+# define COPID_BIT (1L<<30)
+ struct cosh
+ {
+ struct cosh *next;
+ Coshell_t *coshell;
+ Cojob_t *cojob;
+ char *name;
+ short id;
+ };
+
+ extern pid_t sh_copid(struct cosh*);
+ extern char *sh_pid2str(Shell_t*,pid_t);
+#endif /* SHOPT_COSHELL */
+
+#undef JOBS
+#if defined(SIGCLD) && !defined(SIGCHLD)
+# define SIGCHLD SIGCLD
+#endif
+#ifdef SIGCHLD
+# define JOBS 1
+# include "terminal.h"
+# ifdef FIOLOOKLD
+ /* Ninth edition */
+ extern 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 */
+ Shell_t *p_shp; /* shell that posted the job */
+#if SHOPT_COSHELL
+ Cojob_t *p_cojob; /* coshell job */
+#endif /* SHOPT_COSHELL */
+ int *p_exitval; /* place to store the exitval */
+ 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 short p_exitmin; /* minimum exit value for xargs */
+ unsigned short 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 */
+ int *exitval; /* pipe exit values */
+ 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 curjobid;
+ unsigned int in_critical; /* >0 => in critical region */
+ int savesig; /* active signal */
+ int numpost; /* number of posted jobs */
+#ifdef SHOPT_BGX
+ int numbjob; /* number of background jobs */
+#endif /* SHOPT_BGX */
+ short fd; /* tty descriptor number */
+#ifdef JOBS
+ int suspend; /* suspend character */
+ int linedisc; /* line dicipline */
+#endif /* JOBS */
+ 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 */
+#if SHOPT_COSHELL
+ struct cosh *colist; /* coshell job list */
+#endif /* SHOPT_COSHELL */
+};
+
+/* flags for joblist */
+#define JOB_LFLAG 1
+#define JOB_NFLAG 2
+#define JOB_PFLAG 4
+#define JOB_NLFLAG 8
+
+extern struct jobs job;
+
+#ifdef JOBS
+
+#if !_std_malloc
+#include <vmalloc.h>
+#ifdef vmlocked
+#define vmbusy() vmlocked(Vmregion)
+#else
+#if VMALLOC_VERSION >= 20070911L
+#define vmbusy() (vmstat(0,0)!=0)
+#endif
+#endif
+#endif
+#ifndef vmbusy
+#define vmbusy() 0
+#endif
+
+#define job_lock() (job.in_critical++)
+#define job_unlock() \
+ do { \
+ int sig; \
+ if (!--job.in_critical && (sig = job.savesig)) \
+ { \
+ if (!job.in_critical++ && !vmbusy()) \
+ job_reap(sig); \
+ job.in_critical--; \
+ } \
+ } while(0)
+
+extern const char e_jobusage[];
+extern const char e_done[];
+extern const char e_running[];
+extern const char e_coredump[];
+extern const char e_no_proc[];
+extern const char e_no_job[];
+extern const char e_badpid[];
+extern const char e_jobsrunning[];
+extern const char e_nlspace[];
+extern const char e_access[];
+extern const char e_terminate[];
+extern const char e_no_jctl[];
+extern const char e_signo[];
+#ifdef SIGTSTP
+ extern const char e_no_start[];
+#endif /* SIGTSTP */
+#ifdef NTTYDISC
+ extern const char e_newtty[];
+ extern const char e_oldtty[];
+#endif /* NTTYDISC */
+#endif /* JOBS */
+
+/*
+ * The following are defined in jobs.c
+ */
+
+extern void job_clear(void);
+extern void job_bwait(char**);
+extern int job_walk(Sfio_t*,int(*)(struct process*,int),int,char*[]);
+extern int job_kill(struct process*,int);
+extern int job_wait(pid_t);
+extern int job_post(Shell_t*,pid_t,pid_t);
+extern void *job_subsave(void);
+extern void job_subrestore(void*);
+#ifdef SHOPT_BGX
+extern void job_chldtrap(Shell_t*, const char*,int);
+#endif /* SHOPT_BGX */
+#ifdef JOBS
+ extern void job_init(Shell_t*,int);
+ extern int job_close(Shell_t*);
+ extern int job_list(struct process*,int);
+ extern int job_terminate(struct process*,int);
+ extern int job_switch(struct process*,int);
+ extern void job_fork(pid_t);
+ extern int job_reap(int);
+#else
+# define job_init(s,flag)
+# define job_close(s) (0)
+# define job_fork(p)
+#endif /* JOBS */
+
+
+#endif /* !JOB_NFLAG */
diff --git a/src/cmd/ksh93/include/lexstates.h b/src/cmd/ksh93/include/lexstates.h
new file mode 100644
index 0000000..a078e35
--- /dev/null
+++ b/src/cmd/ksh93/include/lexstates.h
@@ -0,0 +1,157 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef S_BREAK
+#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 */
+#define S_BLNK 36 /* space or tab */
+/* The following must be the highest numbered states */
+#define S_QUOTE 37 /* double quote character */
+#define S_GRAVE 38 /* old comsub character */
+#define S_ESC 39 /* escape character */
+#define S_DOL 40 /* $ subsitution character */
+#define S_ESC2 41 /* 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
+
+#include "FEATURE/locale"
+
+#if _hdr_wchar
+# include <wchar.h>
+# if _hdr_wctype
+# include <wctype.h>
+# undef isalpha
+# define isalpha(x) iswalpha(x)
+# if defined(iswblank) || _lib_iswblank
+# undef isblank
+# define isblank(x) iswblank(x)
+# else
+# if _lib_wctype && _lib_iswctype
+# define _lib_iswblank -1
+# undef isblank
+# define isblank(x) local_iswblank(x)
+ extern int local_iswblank(wchar_t);
+# endif
+# endif
+# endif
+#endif
+#ifndef isblank
+# define isblank(x) ((x)==' '||(x)=='\t')
+#endif
+
+#undef LEN
+#if SHOPT_MULTIBYTE
+# define LEN _Fcin.fclen
+# define isaname(c) ((c)>0x7f?isalpha(c): sh_lexstates[ST_NAME][(c)]==0)
+# define isaletter(c) ((c)>0x7f?isalpha(c): sh_lexstates[ST_DOL][(c)]==S_ALP && (c)!='.')
+#else
+# undef mbwide
+# define mbwide() (0)
+# define LEN 1
+# define isaname(c) (sh_lexstates[ST_NAME][c]==0)
+# define isaletter(c) (sh_lexstates[ST_DOL][c]==S_ALP && (c)!='.')
+#endif
+#define STATE(s,c) (s[mbwide()?((c=fcmbget(&LEN)),LEN>1?'a':c):(c=fcget())])
+#define isadigit(c) (sh_lexstates[ST_DOL][c]==S_DIG)
+#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 char *sh_lexstates[ST_NONE];
+extern const char *sh_lexrstates[ST_NONE];
+extern const char e_lexversion[];
+extern const char e_lexspace[];
+extern const char e_lexslash[];
+extern const char e_lexlabignore[];
+extern const char e_lexlabunknown[];
+extern const char e_lexsyntax1[];
+extern const char e_lexsyntax2[];
+extern const char e_lexsyntax3[];
+extern const char e_lexsyntax4[];
+extern const char e_lexsyntax5[];
+extern const char e_lexwarnvar[];
+extern const char e_lexobsolete1[];
+extern const char e_lexobsolete2[];
+extern const char e_lexobsolete3[];
+extern const char e_lexobsolete4[];
+extern const char e_lexobsolete5[];
+extern const char e_lexobsolete6[];
+extern const char e_lexnonstandard[];
+extern const char e_lexusebrace[];
+extern const char e_lexusequote[];
+extern const char e_lexescape[];
+extern const char e_lexquote[];
+extern const char e_lexnested[];
+extern const char e_lexbadchar[];
+extern const char e_lexlongquote[];
+extern const char e_lexfuture[];
+extern const char e_lexzerobyte[];
+extern const char e_lexemptyfor[];
+extern const char e_lextypeset[];
+extern const char e_lexcharclass[];
+#endif
diff --git a/src/cmd/ksh93/include/name.h b/src/cmd/ksh93/include/name.h
new file mode 100644
index 0000000..9768c05
--- /dev/null
+++ b/src/cmd/ksh93/include/name.h
@@ -0,0 +1,268 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _NV_PRIVATE
+/*
+ * This is the implementation header file for name-value pairs
+ */
+
+#define _NV_PRIVATE \
+ Namfun_t *nvfun; /* pointer to trap functions */ \
+ union Value nvalue; /* value field */ \
+ char *nvenv; /* pointer to environment name */
+
+#include <ast.h>
+#include <cdt.h>
+
+typedef int (*Nambfp_f)(int, char**, void*);
+
+/* Nodes can have all kinds of values */
+union Value
+{
+ const char *cp;
+ int *ip;
+ char c;
+ int i;
+ unsigned int u;
+ int32_t *lp;
+ Sflong_t *llp; /* for long long arithmetic */
+ int16_t s;
+ int16_t *sp;
+ double *dp; /* for floating point arithmetic */
+ Sfdouble_t *ldp; /* for long 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 */
+ struct Namfun *funp; /* discipline pointer */
+ struct Namref *nrp; /* name reference */
+ Nambfp_f bfp; /* builtin entry point function pointer */
+};
+
+#include "nval.h"
+
+/* used for arrays */
+
+#define ARRAY_MAX (1L<<ARRAY_BITS) /* maximum number of elements in an array */
+#define ARRAY_MASK (ARRAY_MAX-1) /* For index values */
+
+#define ARRAY_INCR 32 /* number of elements to grow when array
+ bound exceeded. Must be a power of 2 */
+#define ARRAY_FILL (8L<<ARRAY_BITS) /* used with nv_putsub() */
+#define ARRAY_NOCLONE (16L<<ARRAY_BITS) /* do not clone array disc */
+#define ARRAY_NOCHILD (32L<<ARRAY_BITS) /* skip compound arrays */
+#define ARRAY_SETSUB (64L<<ARRAY_BITS) /* set subscript */
+#define ARRAY_NOSCOPE (128L<<ARRAY_BITS) /* top level scope only */
+#define ARRAY_TREE (256L<<ARRAY_BITS) /* arrays of compound vars */
+#if SHOPT_FIXEDARRAY
+# define ARRAY_FIXED ARRAY_NOCLONE /* For index values */
+#endif /* SHOPT_FIXEDARRAY */
+#define NV_FARRAY 0x10000000 /* fixed sized arrays */
+#define NV_ASETSUB 8 /* set subscript */
+
+/* These flags are used as options to array_get() */
+#define ARRAY_ASSIGN 0
+#define ARRAY_LOOKUP 1
+#define ARRAY_DELETE 2
+
+
+struct Namref
+{
+ Namval_t *np;
+ Namval_t *table;
+ Dt_t *root;
+ char *sub;
+#if SHOPT_FIXEDARRAY
+ int curi;
+ char dim;
+#endif /* SHOPT_FIXEDARRAY */
+};
+
+/* This describes a user shell function node */
+struct Ufunction
+{
+ int *ptree; /* address of parse tree */
+ int lineno; /* line number of function start */
+ short argc; /* number of references */
+ char **argv; /* reference argument list */
+ off_t hoffset; /* offset into source or history file */
+ Namval_t *nspace; /* pointer to name space */
+ char *fname; /* file name where function defined */
+ char *help; /* help string */
+ Dt_t *sdict; /* dictionary for statics */
+ Dt_t *fdict; /* dictionary node belongs to */
+ Namval_t *np; /* function node pointer */
+};
+
+#ifndef ARG_RAW
+ struct argnod;
+#endif /* !ARG_RAW */
+
+/* attributes of Namval_t items */
+
+/* The following attributes are for internal use */
+#define NV_NOCHANGE (NV_EXPORT|NV_IMPORT|NV_RDONLY|NV_TAGGED|NV_NOFREE|NV_ARRAY)
+#define NV_ATTRIBUTES (~(NV_NOSCOPE|NV_ARRAY|NV_NOARRAY|NV_IDENT|NV_ASSIGN|NV_REF|NV_VARNAME|NV_STATIC))
+#define NV_PARAM NV_NODISC /* expansion use positional params */
+
+/* This following are for use with nodes which are not name-values */
+#define NV_TYPE 0x1000000
+#define NV_STATIC 0x2000000
+#define NV_COMVAR 0x4000000
+#define NV_UNJUST 0x8000000 /* clear justify attributes */
+#define NV_FUNCTION (NV_RJUST|NV_FUNCT) /* value is shell function */
+#define NV_FPOSIX NV_LJUST /* posix function semantics */
+#define NV_FTMP NV_ZFILL /* function source in tmpfile */
+#define NV_STATICF NV_INTEGER /* static class function */
+
+#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 BLT_NOSFIO (NV_IMPORT) /* doesn't use sfio */
+#define NV_OPTGET (NV_BINARY) /* function calls getopts */
+#define nv_isref(n) (nv_isattr((n),NV_REF|NV_TAGGED|NV_FUNCT)==NV_REF)
+#define is_abuiltin(n) (nv_isattr(n,NV_BLTIN|NV_INTEGER)==NV_BLTIN)
+#define is_afunction(n) (nv_isattr(n,NV_FUNCTION|NV_REF)==NV_FUNCTION)
+#define nv_funtree(n) ((n)->nvalue.rp->ptree)
+#define funptr(n) ((n)->nvalue.bfp)
+
+#define NV_SUBQUOTE (NV_ADD<<1) /* used with nv_endsubscript */
+
+/* NAMNOD MACROS */
+/* ... for attributes */
+
+#define nv_setattr(n,f) ((n)->nvflag = (f))
+#define nv_context(n) ((void*)(n)->nvfun) /* for builtins */
+/* The following are for name references */
+#define nv_refnode(n) ((n)->nvalue.nrp->np)
+#define nv_reftree(n) ((n)->nvalue.nrp->root)
+#define nv_reftable(n) ((n)->nvalue.nrp->table)
+#define nv_refsub(n) ((n)->nvalue.nrp->sub)
+#if SHOPT_FIXEDARRAY
+# define nv_refindex(n) ((n)->nvalue.nrp->curi)
+# define nv_refdimen(n) ((n)->nvalue.nrp->dim)
+#endif /* SHOPT_FIXEDARRAY */
+
+/* ... etc */
+
+#define nv_setsize(n,s) ((n)->nvsize = (s))
+#undef nv_size
+#define nv_size(np) ((np)->nvsize)
+#define _nv_hasget(np) ((np)->nvfun && (np)->nvfun->disc && nv_hasget(np))
+#define nv_isnull(np) (!(np)->nvalue.cp && (nv_isattr(np,NV_SHORT|NV_INTEGER)!=(NV_SHORT|NV_INTEGER)) && !_nv_hasget(np))
+
+/* ... for arrays */
+
+#define array_elem(ap) ((ap)->nelem&ARRAY_MASK)
+#define array_assoc(ap) ((ap)->fun)
+
+extern int array_maxindex(Namval_t*);
+extern char *nv_endsubscript(Namval_t*, char*, int);
+extern Namfun_t *nv_cover(Namval_t*);
+extern Namarr_t *nv_arrayptr(Namval_t*);
+extern int nv_arrayisset(Namval_t*, Namarr_t*);
+extern int nv_arraysettype(Namval_t*, Namval_t*,const char*,int);
+extern int nv_aimax(Namval_t*);
+extern int nv_atypeindex(Namval_t*, const char*);
+extern int nv_setnotify(Namval_t*,char **);
+extern int nv_unsetnotify(Namval_t*,char **);
+extern void nv_setlist(struct argnod*, int, Namval_t*);
+extern struct argnod* nv_onlist(struct argnod*, const char*);
+extern void nv_optimize(Namval_t*);
+extern void nv_outname(Sfio_t*,char*, int);
+extern void nv_unref(Namval_t*);
+extern void _nv_unset(Namval_t*,int);
+extern int nv_hasget(Namval_t*);
+extern int nv_clone(Namval_t*, Namval_t*, int);
+void clone_all_disc(Namval_t*, Namval_t*, int);
+extern Namfun_t *nv_clone_disc(Namfun_t*, int);
+extern void *nv_diropen(Namval_t*, const char*);
+extern char *nv_dirnext(void*);
+extern void nv_dirclose(void*);
+extern char *nv_getvtree(Namval_t*, Namfun_t*);
+extern void nv_attribute(Namval_t*, Sfio_t*, char*, int);
+extern Namval_t *nv_bfsearch(const char*, Dt_t*, Namval_t**, char**);
+extern Namval_t *nv_mkclone(Namval_t*);
+extern Namval_t *nv_mktype(Namval_t**, int);
+extern Namval_t *nv_addnode(Namval_t*, int);
+extern Namval_t *nv_parent(Namval_t*);
+extern char *nv_getbuf(size_t);
+extern Namval_t *nv_mount(Namval_t*, const char *name, Dt_t*);
+extern Namval_t *nv_arraychild(Namval_t*, Namval_t*, int);
+extern int nv_compare(Dt_t*, Void_t*, Void_t*, Dtdisc_t*);
+extern void nv_outnode(Namval_t*,Sfio_t*, int, int);
+extern int nv_subsaved(Namval_t*);
+extern void nv_typename(Namval_t*, Sfio_t*);
+extern void nv_newtype(Namval_t*);
+extern int nv_istable(Namval_t*);
+extern size_t nv_datasize(Namval_t*, size_t*);
+extern Namfun_t *nv_mapchar(Namval_t*, const char*);
+#if SHOPT_FIXEDARRAY
+ extern int nv_arrfixed(Namval_t*, Sfio_t*, int, char*);
+#endif /* SHOPT_FIXEDARRAY */
+
+extern const Namdisc_t RESTRICTED_disc;
+extern const Namdisc_t ENUM_disc;
+extern char nv_local;
+extern Dtdisc_t _Nvdisc;
+extern const char *nv_discnames[];
+extern const char e_subscript[];
+extern const char e_nullset[];
+extern const char e_notset[];
+extern const char e_noparent[];
+extern const char e_notelem[];
+extern const char e_readonly[];
+extern const char e_badfield[];
+extern const char e_restricted[];
+extern const char e_ident[];
+extern const char e_varname[];
+extern const char e_noalias[];
+extern const char e_noarray[];
+extern const char e_notenum[];
+extern const char e_nounattr[];
+extern const char e_aliname[];
+extern const char e_badexport[];
+extern const char e_badref[];
+extern const char e_badsubscript[];
+extern const char e_noref[];
+extern const char e_selfref[];
+extern const char e_staticfun[];
+extern const char e_envmarker[];
+extern const char e_badlocale[];
+extern const char e_loop[];
+extern const char e_redef[];
+extern const char e_required[];
+extern const char e_badappend[];
+extern const char e_unknowntype[];
+extern const char e_unknownmap[];
+extern const char e_mapchararg[];
+extern const char e_subcomvar[];
+extern const char e_badtypedef[];
+extern const char e_typecompat[];
+extern const char e_globalref[];
+extern const char e_tolower[];
+extern const char e_toupper[];
+#endif /* _NV_PRIVATE */
diff --git a/src/cmd/ksh93/include/national.h b/src/cmd/ksh93/include/national.h
new file mode 100644
index 0000000..4c1888b
--- /dev/null
+++ b/src/cmd/ksh93/include/national.h
@@ -0,0 +1,37 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * national.h - definitions for multibyte character sets
+ *
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#if SHOPT_MULTIBYTE
+
+# ifndef MARKER
+# define MARKER 0xdfff /* Must be invalid character */
+# endif
+
+ extern int sh_strchr(const char*,const char*);
+
+#endif /* SHOPT_MULTIBYTE */
diff --git a/src/cmd/ksh93/include/nval.h b/src/cmd/ksh93/include/nval.h
new file mode 100644
index 0000000..6d8a503
--- /dev/null
+++ b/src/cmd/ksh93/include/nval.h
@@ -0,0 +1,311 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef NV_DEFAULT
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions of structures for name-value pairs
+ * These structures are used for named variables, functions and aliases
+ *
+ */
+
+
+#include <ast.h>
+#include <cdt.h>
+#include <option.h>
+
+/* for compatibility with old hash library */
+#define Hashtab_t Dt_t
+#define HASH_BUCKET 1
+#define HASH_NOSCOPE 2
+#define HASH_SCOPE 4
+#define hashscope(x) dtvnext(x)
+
+typedef struct Namval Namval_t;
+typedef struct Namfun Namfun_t;
+typedef struct Namdisc Namdisc_t;
+typedef struct Nambfun Nambfun_t;
+typedef struct Namarray Namarr_t;
+typedef struct Namdecl Namdecl_t;
+
+/*
+ * This defines the template for nodes that have their own assignment
+ * and or lookup functions
+ */
+struct Namdisc
+{
+ size_t dsize;
+ void (*putval)(Namval_t*, const char*, int, Namfun_t*);
+ char *(*getval)(Namval_t*, Namfun_t*);
+ Sfdouble_t (*getnum)(Namval_t*, Namfun_t*);
+ char *(*setdisc)(Namval_t*, const char*, Namval_t*, Namfun_t*);
+ Namval_t *(*createf)(Namval_t*, const char*, int, Namfun_t*);
+ Namfun_t *(*clonef)(Namval_t*, Namval_t*, int, Namfun_t*);
+ char *(*namef)(Namval_t*, Namfun_t*);
+ Namval_t *(*nextf)(Namval_t*, Dt_t*, Namfun_t*);
+ Namval_t *(*typef)(Namval_t*, Namfun_t*);
+ int (*readf)(Namval_t*, Sfio_t*, int, Namfun_t*);
+ int (*writef)(Namval_t*, Sfio_t*, int, Namfun_t*);
+};
+
+struct Namfun
+{
+ const Namdisc_t *disc;
+ char nofree;
+ unsigned char subshell;
+ unsigned short dsize;
+ Namfun_t *next;
+ char *last;
+ Namval_t *type;
+};
+
+struct Nambfun
+{
+ Namfun_t fun;
+ int num;
+ const char **bnames;
+ Namval_t *bltins[1];
+};
+
+/* This is an array template header */
+struct Namarray
+{
+ Namfun_t hdr;
+ long nelem; /* number of elements */
+ void *(*fun)(Namval_t*,const char*,int); /* associative arrays */
+ void *fixed; /* for fixed sized arrays */
+ Dt_t *table; /* for subscripts */
+ void *scope; /* non-zerp when scoped */
+};
+
+/* The context pointer for declaration command */
+struct Namdecl
+{
+ Namval_t *tp; /* point to type */
+ const char *optstring;
+ void *optinfof;
+};
+
+/* attributes of name-value node attribute flags */
+
+#define NV_DEFAULT 0
+/* This defines the attributes for an attributed name-value pair node */
+struct Namval
+{
+ Dtlink_t nvlink; /* space for cdt links */
+ char *nvname; /* pointer to name of the node */
+ unsigned short nvflag; /* attributes */
+ unsigned short nvsize; /* size or base */
+#ifdef _NV_PRIVATE
+ _NV_PRIVATE
+#else
+ Namfun_t *nvfun;
+ char *nvalue;
+ char *nvprivate;
+#endif /* _NV_PRIVATE */
+};
+
+#define NV_CLASS ".sh.type"
+#define NV_DATA "_" /* special class or instance variable */
+#define NV_MINSZ (sizeof(struct Namval)-sizeof(Dtlink_t)-sizeof(char*))
+#define nv_namptr(p,n) ((Namval_t*)((char*)(p)+(n)*NV_MINSZ-sizeof(Dtlink_t)))
+
+/* The following attributes are for internal use */
+#define NV_NOFREE 0x200 /* don't free the space when releasing value */
+#define NV_ARRAY 0x400 /* node is an array */
+#define NV_REF 0x4000 /* reference bit */
+#define NV_TABLE 0x800 /* node is a dictionary table */
+#define NV_IMPORT 0x1000 /* value imported from environment */
+#define NV_MINIMAL NV_IMPORT /* node does not contain all fields */
+
+#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 */
+#define NV_BINARY 0x100 /* fixed size data buffer */
+#define NV_RAW NV_LJUST /* used only with NV_BINARY */
+#define NV_HOST (NV_RJUST|NV_LJUST) /* map to host filename */
+
+/* The following attributes do not effect the value */
+#define NV_RDONLY 0x1 /* readonly bit */
+#define NV_EXPORT 0x2000 /* export bit */
+#define NV_TAGGED 0x8000 /* user define tag bit */
+
+/* The following are used with NV_INTEGER */
+#define NV_SHORT (NV_RJUST) /* when integers are not long */
+#define NV_LONG (NV_UTOL) /* for long long and long double */
+#define NV_UNSIGN (NV_LTOU) /* for unsigned quantities */
+#define NV_DOUBLE (NV_INTEGER|NV_ZFILL) /* for floating point */
+#define NV_EXPNOTE (NV_LJUST) /* for scientific notation */
+#define NV_HEXFLOAT (NV_LTOU) /* for C99 base16 float notation */
+
+/* options for nv_open */
+
+#define NV_APPEND 0x10000 /* append value */
+#define NV_MOVE 0x8000000 /* for use with nv_clone */
+#define NV_ADD 8
+ /* add node if not found */
+#define NV_ASSIGN NV_NOFREE /* assignment is possible */
+#define NV_NOASSIGN 0 /* backward compatibility */
+#define NV_NOARRAY 0x200000 /* array name not possible */
+#define NV_IARRAY 0x400000 /* for indexed array */
+#define NV_NOREF NV_REF /* don't follow reference */
+#define NV_IDENT 0x80 /* name must be identifier */
+#define NV_VARNAME 0x20000 /* name must be ?(.)id*(.id) */
+#define NV_NOADD 0x40000 /* do not add node */
+#define NV_NOSCOPE 0x80000 /* look only in current scope */
+#define NV_NOFAIL 0x100000 /* return 0 on failure, no msg */
+#define NV_NODISC NV_IDENT /* ignore disciplines */
+
+#define NV_FUNCT NV_IDENT /* option for nv_create */
+#define NV_BLTINOPT NV_ZFILL /* mark builtins in libcmd */
+
+#define NV_PUBLIC (~(NV_NOSCOPE|NV_ASSIGN|NV_IDENT|NV_VARNAME|NV_NOADD))
+
+/* numeric types */
+#define NV_INT16P (NV_LJUST|NV_SHORT|NV_INTEGER)
+#define NV_INT16 (NV_SHORT|NV_INTEGER)
+#define NV_UINT16 (NV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_UINT16P (NV_LJUSTNV_UNSIGN|NV_SHORT|NV_INTEGER)
+#define NV_INT32 (NV_INTEGER)
+#define NV_UNT32 (NV_UNSIGN|NV_INTEGER)
+#define NV_INT64 (NV_LONG|NV_INTEGER)
+#define NV_UINT64 (NV_UNSIGN|NV_LONG|NV_INTEGER)
+#define NV_FLOAT (NV_SHORT|NV_DOUBLE)
+#define NV_LDOUBLE (NV_LONG|NV_DOUBLE)
+
+/* name-value pair macros */
+#define nv_isattr(np,f) ((np)->nvflag & (f))
+#define nv_onattr(n,f) ((n)->nvflag |= (f))
+#define nv_offattr(n,f) ((n)->nvflag &= ~(f))
+#define nv_isarray(np) (nv_isattr((np),NV_ARRAY))
+
+/* 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 */
+#define NV_ACURRENT 7 /* return current subscript Namval_t* */
+#define NV_ASETSUB 8 /* set current subscript */
+
+/* The following are for nv_disc */
+#define NV_FIRST 1
+#define NV_LAST 2
+#define NV_POP 3
+#define NV_CLONE 4
+
+/* The following are operations for nv_putsub() */
+#define ARRAY_BITS 22
+#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} */
+
+
+/* These are disciplines provided by the library for use with nv_discfun */
+#define NV_DCADD 0 /* used to add named disciplines */
+#define NV_DCRESTRICT 1 /* variable that are restricted in rsh */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+# define extern __EXPORT__
+# else
+# define extern __IMPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+/* prototype for array interface*/
+extern Namarr_t *nv_arrayptr(Namval_t*);
+extern Namarr_t *nv_setarray(Namval_t*,void*(*)(Namval_t*,const char*,int));
+extern int nv_arraynsub(Namarr_t*);
+extern void *nv_associative(Namval_t*,const char*,int);
+extern int nv_aindex(Namval_t*);
+extern int nv_nextsub(Namval_t*);
+extern char *nv_getsub(Namval_t*);
+extern Namval_t *nv_putsub(Namval_t*, char*, long);
+extern Namval_t *nv_opensub(Namval_t*);
+
+/* name-value pair function prototypes */
+extern int nv_adddisc(Namval_t*, const char**, Namval_t**);
+extern int nv_clone(Namval_t*, Namval_t*, int);
+extern void nv_close(Namval_t*);
+extern void *nv_context(Namval_t*);
+extern Namval_t *nv_create(const char*, Dt_t*, int,Namfun_t*);
+extern void nv_delete(Namval_t*, Dt_t*, int);
+extern Dt_t *nv_dict(Namval_t*);
+extern Sfdouble_t nv_getn(Namval_t*, Namfun_t*);
+extern Sfdouble_t nv_getnum(Namval_t*);
+extern char *nv_getv(Namval_t*, Namfun_t*);
+extern char *nv_getval(Namval_t*);
+extern Namfun_t *nv_hasdisc(Namval_t*, const Namdisc_t*);
+extern int nv_isnull(Namval_t*);
+extern Namfun_t *nv_isvtree(Namval_t*);
+extern Namval_t *nv_lastdict(void);
+extern Namval_t *nv_mkinttype(char*, size_t, int, const char*, Namdisc_t*);
+extern void nv_newattr(Namval_t*,unsigned,int);
+extern void nv_newtype(Namval_t*);
+extern Namval_t *nv_open(const char*,Dt_t*,int);
+extern void nv_putval(Namval_t*,const char*,int);
+extern void nv_putv(Namval_t*,const char*,int,Namfun_t*);
+extern int nv_rename(Namval_t*,int);
+extern int nv_scan(Dt_t*,void(*)(Namval_t*,void*),void*,int,int);
+extern char *nv_setdisc(Namval_t*,const char*,Namval_t*,Namfun_t*);
+extern void nv_setref(Namval_t*, Dt_t*,int);
+extern int nv_settype(Namval_t*, Namval_t*, int);
+extern void nv_setvec(Namval_t*,int,int,char*[]);
+extern void nv_setvtree(Namval_t*);
+extern int nv_setsize(Namval_t*,int);
+extern Namfun_t *nv_disc(Namval_t*,Namfun_t*,int);
+extern void nv_unset(Namval_t*); /*obsolete */
+extern void _nv_unset(Namval_t*,int);
+extern Namval_t *nv_search(const char *, Dt_t*, int);
+extern char *nv_name(Namval_t*);
+extern Namval_t *nv_type(Namval_t*);
+extern void nv_addtype(Namval_t*,const char*, Optdisc_t*, size_t);
+extern const Namdisc_t *nv_discfun(int);
+
+#ifdef _DLL
+# undef extern
+#endif /* _DLL */
+
+#define nv_unset(np) _nv_unset(np,0)
+#define nv_size(np) nv_setsize((np),-1)
+#define nv_stack(np,nf) nv_disc(np,nf,0)
+
+#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,0)
+# 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 */
diff --git a/src/cmd/ksh93/include/path.h b/src/cmd/ksh93/include/path.h
new file mode 100644
index 0000000..f15dc4c
--- /dev/null
+++ b/src/cmd/ksh93/include/path.h
@@ -0,0 +1,147 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef PATH_OFFSET
+
+/*
+ * UNIX shell path handling interface
+ * Written by David Korn
+ * These are the definitions for the lexical analyzer
+ */
+
+#include "FEATURE/options"
+#include <nval.h>
+#include "defs.h"
+
+#if !defined(SHOPT_SPAWN)
+# if _UWIN || _use_spawnveg || !_lib_fork
+# define SHOPT_SPAWN 1
+# endif
+#endif /* !SHOPT_SPAWN */
+
+#define PATH_PATH 0001
+#define PATH_FPATH 0002
+#define PATH_CDPATH 0004
+#define PATH_BFPATH 0010
+#define PATH_SKIP 0020
+#define PATH_BUILTIN_LIB 0040
+#define PATH_STD_DIR 0100 /* directory is on $(getconf PATH) */
+
+#define PATH_OFFSET 2 /* path offset for path_join */
+#define MAXDEPTH (sizeof(char*)==2?64:1024) /* maximum recursion depth*/
+
+/*
+ * path component structure for path searching
+ */
+typedef struct pathcomp
+{
+ struct pathcomp *next;
+ int refcount;
+ dev_t dev;
+ ino_t ino;
+ time_t mtime;
+ char *name;
+ char *lib;
+ char *blib;
+ void *bltin_lib;
+ unsigned short len;
+ unsigned short flags;
+ Shell_t *shp;
+} Pathcomp_t;
+
+#ifndef ARG_RAW
+ struct argnod;
+#endif /* !ARG_RAW */
+
+/* pathname handling routines */
+extern void path_newdir(Shell_t*,Pathcomp_t*);
+extern Pathcomp_t *path_dirfind(Pathcomp_t*,const char*,int);
+extern Pathcomp_t *path_unsetfpath(Shell_t*);
+extern Pathcomp_t *path_addpath(Shell_t*,Pathcomp_t*,const char*,int);
+extern Pathcomp_t *path_dup(Pathcomp_t*);
+extern void path_delete(Pathcomp_t*);
+extern void path_alias(Namval_t*,Pathcomp_t*);
+extern Pathcomp_t *path_absolute(Shell_t*, const char*, Pathcomp_t*);
+extern char *path_basename(const char*);
+extern char *path_fullname(Shell_t*,const char*);
+extern int path_expand(Shell_t*,const char*, struct argnod**);
+extern void path_exec(Shell_t*,const char*,char*[],struct argnod*);
+extern pid_t path_spawn(Shell_t*,const char*,char*[],char*[],Pathcomp_t*,int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+# define extern __EXPORT__
+#endif
+extern int path_open(Shell_t*,const char*,Pathcomp_t*);
+extern Pathcomp_t *path_get(Shell_t*,const char*);
+#undef extern
+extern char *path_pwd(Shell_t*,int);
+extern Pathcomp_t *path_nextcomp(Shell_t*,Pathcomp_t*,const char*,Pathcomp_t*);
+extern int path_search(Shell_t*,const char*,Pathcomp_t**,int);
+extern char *path_relative(Shell_t*,const char*);
+extern int path_complete(Shell_t*,const char*, const char*,struct argnod**);
+#if SHOPT_BRACEPAT
+ extern int path_generate(Shell_t*,struct argnod*,struct argnod**);
+#endif /* SHOPT_BRACEPAT */
+#if SHOPT_PFSH
+ extern int path_xattr(Shell_t*, const char*, char*);
+#endif /* SHOPT_PFSH */
+
+/* constant strings needed for whence */
+extern const char e_timeformat[];
+extern const char e_badtformat[];
+extern const char e_dot[];
+extern const char e_funload[];
+extern const char e_pfsh[];
+extern const char e_pwd[];
+extern const char e_logout[];
+extern const char e_alphanum[];
+extern const char e_mailmsg[];
+extern const char e_suidprofile[];
+extern const char e_sysprofile[];
+extern const char e_traceprompt[];
+extern const char e_crondir[];
+#if SHOPT_SUID_EXEC
+ extern const char e_suidexec[];
+#endif /* SHOPT_SUID_EXEC */
+extern const char is_alias[];
+extern const char is_builtin[];
+extern const char is_spcbuiltin[];
+extern const char is_builtver[];
+extern const char is_reserved[];
+extern const char is_talias[];
+extern const char is_xalias[];
+extern const char is_function[];
+extern const char is_ufunction[];
+#ifdef SHELLMAGIC
+ extern const char e_prohibited[];
+#endif /* SHELLMAGIC */
+
+#if SHOPT_ACCT
+# include "FEATURE/acct"
+# ifdef _sys_acct
+ extern void sh_accinit(void);
+ extern void sh_accbegin(const char*);
+ extern void sh_accend(void);
+ extern void sh_accsusp(void);
+# else
+# undef SHOPT_ACCT
+# endif /* _sys_acct */
+#endif /* SHOPT_ACCT */
+
+#endif /*! PATH_OFFSET */
diff --git a/src/cmd/ksh93/include/regress.h b/src/cmd/ksh93/include/regress.h
new file mode 100644
index 0000000..83c1824
--- /dev/null
+++ b/src/cmd/ksh93/include/regress.h
@@ -0,0 +1,66 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Shell interface private definitions
+ *
+ */
+
+#ifndef _REGRESS_H
+#define _REGRESS_H 1
+
+#if SHOPT_REGRESS
+
+typedef struct Regress_s
+{
+ Shopt_t options;
+} Regress_t;
+
+#define sh_isregress(r) is_option(&sh.regress->options,r)
+#define sh_onregress(r) on_option(&sh.regress->options,r)
+#define sh_offregress(r) off_option(&sh.regress->options,r)
+
+#define REGRESS(r,i,f) do { if (sh_isregress(REGRESS_##r)) sh_regress(REGRESS_##r, i, sfprints f, __LINE__, __FILE__); } while (0)
+
+#define REGRESS_egid 1
+#define REGRESS_euid 2
+#define REGRESS_p_suid 3
+#define REGRESS_source 4
+#define REGRESS_etc 5
+
+#undef SHOPT_P_SUID
+#define SHOPT_P_SUID sh_regress_p_suid(__LINE__, __FILE__)
+
+extern int b___regress__(int, char**, Shbltin_t*);
+extern void sh_regress_init(Shell_t*);
+extern void sh_regress(unsigned int, const char*, const char*, unsigned int, const char*);
+extern uid_t sh_regress_p_suid(unsigned int, const char*);
+extern char* sh_regress_etc(const char*, unsigned int, const char*);
+
+#else
+
+#define REGRESS(r,i,f)
+
+#endif /* SHOPT_REGRESS */
+
+#endif /* _REGRESS_H */
diff --git a/src/cmd/ksh93/include/shell.h b/src/cmd/ksh93/include/shell.h
new file mode 100644
index 0000000..ac80629
--- /dev/null
+++ b/src/cmd/ksh93/include/shell.h
@@ -0,0 +1,259 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SH_INTERACTIVE
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions for shell command language
+ *
+ */
+
+#define SH_VERSION 20071012
+
+#include <ast.h>
+#include <cdt.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 struct
+{
+ unsigned long v[4];
+}
+Shopt_t;
+
+typedef struct Shell_s Shell_t;
+
+#include <shcmd.h>
+
+typedef void (*Shinit_f)(Shell_t*, int);
+#ifndef SH_wait_f_defined
+ typedef int (*Shwait_f)(int, long, int);
+# define SH_wait_f_defined
+#endif
+
+union Shnode_u;
+typedef union Shnode_u Shnode_t;
+
+#define SH_CFLAG 0
+#define SH_HISTORY 1 /* used also as a state */
+#define SH_ERREXIT 2 /* used also as a state */
+#define SH_VERBOSE 3 /* used also as a state */
+#define SH_MONITOR 4 /* used also as a state */
+#define SH_INTERACTIVE 5 /* used also as a state */
+#define SH_RESTRICTED 6
+#define SH_XTRACE 7
+#define SH_KEYWORD 8
+#define SH_NOUNSET 9
+#define SH_NOGLOB 10
+#define SH_ALLEXPORT 11
+#define SH_PFSH 12
+#define SH_IGNOREEOF 13
+#define SH_NOCLOBBER 14
+#define SH_MARKDIRS 15
+#define SH_BGNICE 16
+#define SH_VI 17
+#define SH_VIRAW 18
+#define SH_TFLAG 19
+#define SH_TRACKALL 20
+#define SH_SFLAG 21
+#define SH_NOEXEC 22
+#define SH_GMACS 24
+#define SH_EMACS 25
+#define SH_PRIVILEGED 26
+#define SH_SUBSHARE 27 /* subshell shares state with parent */
+#define SH_NOLOG 28
+#define SH_NOTIFY 29
+#define SH_DICTIONARY 30
+#define SH_PIPEFAIL 32
+#define SH_GLOBSTARS 33
+#define SH_XARGS 34
+#define SH_RC 35
+#define SH_SHOWME 36
+#define SH_LETOCTAL 37
+
+/*
+ * passed as flags to builtins in Nambltin_t struct when BLT_OPTIM is on
+ */
+#define SH_BEGIN_OPTIM 0x1
+#define SH_END_OPTIM 0x2
+
+/* The following type is used for error messages */
+
+/* error messages */
+extern const char e_defpath[];
+extern const char e_found[];
+extern const char e_nospace[];
+extern const char e_format[];
+extern const char e_number[];
+extern const char e_restricted[];
+extern const char e_recursive[];
+extern char e_version[];
+
+typedef struct sh_scope
+{
+ struct sh_scope *par_scope;
+ int argc;
+ char **argv;
+ char *cmdname;
+ char *filename;
+ char *funname;
+ int lineno;
+ Dt_t *var_tree;
+ struct sh_scope *self;
+} Shscope_t;
+
+/*
+ * Saves the state of the shell
+ */
+
+struct Shell_s
+{
+ Shopt_t options; /* set -o options */
+ Dt_t *var_tree; /* for shell variables */
+ Dt_t *fun_tree; /* for shell functions */
+ Dt_t *alias_tree; /* for alias names */
+ Dt_t *bltin_tree; /* for builtin commands */
+ Shscope_t *topscope; /* pointer to top-level scope */
+ int inlineno; /* line number of current input file */
+ int exitval; /* most recent exit value */
+ unsigned char trapnote; /* set when trap/signal is pending */
+ char shcomp; /* set when runing shcomp */
+ short subshell; /* set for virtual subshell */
+#ifdef _SH_PRIVATE
+ _SH_PRIVATE
+#endif /* _SH_PRIVATE */
+};
+
+/* flags for sh_parse */
+#define SH_NL 1 /* Treat new-lines as ; */
+#define SH_EOF 2 /* EOF causes syntax error */
+
+/* symbolic values for sh_iogetiop */
+#define SH_IOCOPROCESS (-2)
+#define SH_IOHISTFILE (-3)
+
+#include <cmd.h>
+
+/* symbolic value for sh_fdnotify */
+#define SH_FDCLOSE (-1)
+
+#undef getenv /* -lshell provides its own */
+
+#if defined(__EXPORT__) && defined(_DLL)
+# ifdef _BLD_shell
+# define extern __EXPORT__
+# endif /* _BLD_shell */
+#endif /* _DLL */
+
+extern Dt_t *sh_bltin_tree(void);
+extern void sh_subfork(void);
+extern Shell_t *sh_init(int,char*[],Shinit_f);
+extern int sh_reinit(char*[]);
+extern int sh_eval(Sfio_t*,int);
+extern void sh_delay(double);
+extern void *sh_parse(Shell_t*, Sfio_t*,int);
+extern int sh_trap(const char*,int);
+extern int sh_fun(Namval_t*,Namval_t*, char*[]);
+extern int sh_funscope(int,char*[],int(*)(void*),void*,int);
+extern Sfio_t *sh_iogetiop(int,int);
+extern int sh_main(int, char*[], Shinit_f);
+extern int sh_run(int, char*[]);
+extern void sh_menu(Sfio_t*, int, char*[]);
+extern Namval_t *sh_addbuiltin(const char*, int(*)(int, char*[],Shbltin_t*), void*);
+extern char *sh_fmtq(const char*);
+extern char *sh_fmtqf(const char*, int, int);
+extern Sfdouble_t sh_strnum(const char*, char**, int);
+extern int sh_access(const char*,int);
+extern int sh_close(int);
+extern int sh_dup(int);
+extern void sh_exit(int);
+extern int sh_fcntl(int, int, ...);
+extern Sfio_t *sh_fd2sfio(int);
+extern int (*sh_fdnotify(int(*)(int,int)))(int,int);
+extern Shell_t *sh_getinterp(void);
+extern int sh_open(const char*, int, ...);
+extern int sh_openmax(void);
+extern Sfio_t *sh_pathopen(const char*);
+extern ssize_t sh_read(int, void*, size_t);
+extern ssize_t sh_write(int, const void*, size_t);
+extern off_t sh_seek(int, off_t, int);
+extern int sh_pipe(int[]);
+extern mode_t sh_umask(mode_t);
+extern void *sh_waitnotify(Shwait_f);
+extern Shscope_t *sh_getscope(int,int);
+extern Shscope_t *sh_setscope(Shscope_t*);
+extern void sh_sigcheck(void);
+extern unsigned long sh_isoption(int);
+extern unsigned long sh_onoption(int);
+extern unsigned long sh_offoption(int);
+extern int sh_waitsafe(void);
+extern int sh_exec(const Shnode_t*,int);
+
+#if SHOPT_DYNAMIC
+ extern void **sh_getliblist(void);
+#endif /* SHOPT_DYNAMIC */
+
+/*
+ * direct access to sh is obsolete, use sh_getinterp() instead
+ */
+#if !defined(_SH_PRIVATE) && defined(__IMPORT__) && !defined(_BLD_shell)
+ extern __IMPORT__ Shell_t sh;
+#else
+ extern Shell_t sh;
+#endif
+
+#ifdef _DLL
+# undef extern
+#endif /* _DLL */
+
+#ifndef _SH_PRIVATE
+# define access(a,b) sh_access(a,b)
+# define close(a) sh_close(a)
+# define exit(a) sh_exit(a)
+# define fcntl(a,b,c) sh_fcntl(a,b,c)
+# 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 umask(a) sh_umask(a)
+# define dup sh_dup
+# if _lib_lseek64
+# define open64 sh_open
+# define lseek64 sh_seek
+# else
+# define open sh_open
+# define lseek sh_seek
+# endif
+#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 */
+
+#endif /* SH_INTERACTIVE */
diff --git a/src/cmd/ksh93/include/shlex.h b/src/cmd/ksh93/include/shlex.h
new file mode 100644
index 0000000..b8e5034
--- /dev/null
+++ b/src/cmd/ksh93/include/shlex.h
@@ -0,0 +1,171 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef NOTSYM
+/*
+ * UNIX shell
+ * Written by David Korn
+ * These are the definitions for the lexical analyzer
+ */
+
+#include <cdt.h>
+#include "FEATURE/options"
+#include "shnodes.h"
+#include "shtable.h"
+#include "lexstates.h"
+
+
+typedef struct _shlex_
+{
+ Shell_t *sh; /* pointer to the interpreter */
+ 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 */
+ int nonstandard; /* nonstandard construct in profile */
+ char aliasok; /* on when alias is legal */
+ char assignok; /* on when name=value is legal */
+ char inexec; /* on when processing exec */
+ char intypeset; /* on when processing typeset */
+ char comp_assign; /* in compound assignment */
+ char comsub; /* parsing command substitution */
+ char noreserv; /* reserved works not legal */
+ int inlineno; /* saved value of sh.inlineno */
+ int firstline; /* saved value of sh.st.firstline */
+#if SHOPT_KIA
+ Sfio_t *kiafile; /* kia output file */
+ Sfio_t *kiatmp; /* kia reference file */
+ unsigned long script; /* script entity number */
+ unsigned long fscript; /* script file entity number */
+ unsigned long current; /* current entity number */
+ unsigned long unknown; /* <unknown> entity number */
+ off_t kiabegin; /* offset of first entry */
+ char *scriptname; /* name of script file */
+ Dt_t *entity_tree; /* for entity ids */
+#endif /* SHOPT_KIA */
+#ifdef _SHLEX_PRIVATE
+ _SHLEX_PRIVATE
+#endif
+} Lex_t;
+
+/* 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 NSPACESYM (SYMRES|021)
+
+#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 SYMSEMI 0110000 /* trailing ';' */
+#define SYMSHARP 0120000 /* trailing '#' */
+#define IOSEEKSYM (SYMSHARP|'<')
+#define IOMOV0SYM (SYMAMP|'<')
+#define IOMOV1SYM (SYMAMP|'>')
+#define FALLTHRUSYM (SYMAMP|';')
+#define COOPSYM (SYMAMP|'|')
+#define IORDWRSYM (SYMGT|'<')
+#define IORDWRSYMT (SYMSEMI|'<')
+#define IOCLOBSYM (SYMPIPE|'>')
+#define PIPESYM2 (SYMPIPE|'&')
+#define IPROCSYM (SYMLPAR|'<')
+#define OPROCSYM (SYMLPAR|'>')
+#define EOFSYM 04000 /* end-of-file */
+#define TESTUNOP 04001
+#define TESTBINOP 04002
+#define LABLSYM 04003
+#define IOVNAME 04004
+
+/* additional parser flag, others in <shell.h> */
+#define SH_EMPTY 04
+#define SH_NOIO 010
+#define SH_ASSIGN 020
+#define SH_FUNDEF 040
+#define SH_ARRAY 0100
+#define SH_SEMI 0200 /* semi-colon after NL ok */
+
+#define SH_COMPASSIGN 010 /* allow compound assignments only */
+
+#if 0
+typedef struct _shlex_
+{
+ struct shlex_t _shlex;
+#ifdef _SHLEX_PRIVATE
+ _SHLEX_PRIVATE
+#endif
+} Lex_t;
+
+#define shlex (((Lex_t*)(sh.lex_context))->_shlex)
+#endif
+extern const char e_unexpected[];
+extern const char e_unmatched[];
+extern const char e_endoffile[];
+extern const char e_newline[];
+
+/* odd chars */
+#define LBRACE '{'
+#define RBRACE '}'
+#define LPAREN '('
+#define RPAREN ')'
+#define LBRACT '['
+#define RBRACT ']'
+
+extern int sh_lex(Lex_t*);
+extern Shnode_t *sh_dolparen(Lex_t*);
+extern Lex_t *sh_lexopen(Lex_t*, Shell_t*, int);
+extern void sh_lexskip(Lex_t*,int,int,int);
+extern void sh_syntax(Lex_t*);
+#if SHOPT_KIA
+ extern int kiaclose(Lex_t *);
+ extern unsigned long kiaentity(Lex_t*, const char*,int,int,int,int,unsigned long,int,int,const char*);
+#endif /* SHOPT_KIA */
+
+
+#endif /* !NOTSYM */
diff --git a/src/cmd/ksh93/include/shnodes.h b/src/cmd/ksh93/include/shnodes.h
new file mode 100644
index 0000000..6e0eb55
--- /dev/null
+++ b/src/cmd/ksh93/include/shnodes.h
@@ -0,0 +1,221 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _SHNODES_H
+#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 FSHOWME (0400<<COMBITS) /* set for showme commands */
+#define FALTPIPE (02000<<COMBITS) /* alternate pipes &| */
+#define FPOSIX (02<<COMBITS) /* posix semantics function */
+#define FLINENO (04<<COMBITS) /* for/case has line number */
+#define FOPTGET (010<<COMBITS) /* function calls getopts */
+
+#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 TNSPACE (TFUN|COMSCAN)
+
+#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;
+ Shnode_t *forktre;
+ int forkline;
+};
+
+
+struct ifnod
+{
+ int iftyp;
+ Shnode_t *iftre;
+ Shnode_t *thtre;
+ Shnode_t *eltre;
+};
+
+struct whnod
+{
+ int whtyp;
+ Shnode_t *whtre;
+ Shnode_t *dotre;
+ struct arithnod *whinc;
+};
+
+struct fornod
+{
+ int fortyp;
+ char *fornam;
+ Shnode_t *fortre;
+ struct comnod *forlst;
+ int forline;
+};
+
+struct swnod
+{
+ int swtyp;
+ struct argnod *swarg;
+ struct regnod *swlst;
+ struct ionod *swio;
+ int swline;
+};
+
+struct regnod
+{
+ struct argnod *regptr;
+ Shnode_t *regcom;
+ struct regnod *regnxt;
+ char regflag;
+};
+
+struct parnod
+{
+ int partyp;
+ Shnode_t *partre;
+};
+
+struct lstnod
+{
+ int lsttyp;
+ Shnode_t *lstlef;
+ Shnode_t *lstrit;
+};
+
+/* tst is same as lst, but with extra field for line number */
+struct tstnod
+{
+ struct lstnod tstlst;
+ int tstline;
+};
+
+struct functnod
+{
+ int functtyp;
+ char *functnam;
+ Shnode_t *functtre;
+ int functline;
+ off_t functloc;
+ struct slnod *functstak;
+ struct comnod *functargs;
+};
+
+struct arithnod
+{
+ int artyp;
+ int arline;
+ struct argnod *arexpr;
+ void *arcomp;
+};
+
+
+/* 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 */
+#define IOVNM 0x10000 /* iovname field is non-zero */
+#define IOLSEEK 0x20000 /* seek operators <# or ># */
+#define IOARITH 0x40000 /* arithmetic seek <# ((expr)) */
+#define IOREWRITE 0x80000 /* arithmetic seek <# ((expr)) */
+#define IOCOPY IOCLOB /* copy skipped lines onto standard output */
+#define IOPROCSUB IOARITH /* process substitution redirection */
+
+union Shnode_u
+{
+ 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 void sh_freeup(Shell_t*);
+extern void sh_funstaks(struct slnod*,int);
+extern Sfio_t *sh_subshell(Shell_t*,Shnode_t*, int, int);
+#if defined(__EXPORT__) && defined(_BLD_DLL) && defined(_BLD_shell)
+ __EXPORT__
+#endif
+extern int sh_tdump(Sfio_t*, const Shnode_t*);
+extern Shnode_t *sh_trestore(Shell_t*, Sfio_t*);
+
+#endif /* _SHNODES_H */
diff --git a/src/cmd/ksh93/include/shtable.h b/src/cmd/ksh93/include/shtable.h
new file mode 100644
index 0000000..e851ae5
--- /dev/null
+++ b/src/cmd/ksh93/include/shtable.h
@@ -0,0 +1,65 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _SHTABLE_H
+
+/*
+ * David Korn
+ * AT&T Labs
+ *
+ * Interface definitions read-only data tables for shell
+ *
+ */
+
+#define _SHTABLE_H 1
+
+typedef struct shtable1
+{
+ const char *sh_name;
+ const unsigned sh_number;
+} Shtable_t;
+
+struct shtable2
+{
+ const char *sh_name;
+ const unsigned sh_number;
+ const char *sh_value;
+};
+
+struct shtable3
+{
+ const char *sh_name;
+ const unsigned sh_number;
+ int (*sh_value)(int, char*[], Shbltin_t*);
+};
+
+#define sh_lookup(name,value) (sh_locate(name,(Shtable_t*)(value),sizeof(*(value)))->sh_number)
+extern const Shtable_t shtab_testops[];
+extern const Shtable_t shtab_options[];
+extern const Shtable_t shtab_attributes[];
+extern const struct shtable2 shtab_variables[];
+extern const struct shtable2 shtab_aliases[];
+extern const struct shtable2 shtab_signals[];
+extern const struct shtable3 shtab_builtins[];
+extern const Shtable_t shtab_reserved[];
+extern const Shtable_t *sh_locate(const char*, const Shtable_t*, int);
+extern int sh_lookopt(const char*, int*);
+
+#endif /* SH_TABLE_H */
diff --git a/src/cmd/ksh93/include/streval.h b/src/cmd/ksh93/include/streval.h
new file mode 100644
index 0000000..30008b5
--- /dev/null
+++ b/src/cmd/ksh93/include/streval.h
@@ -0,0 +1,207 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef SEQPOINT
+/*
+ * D. G. Korn
+ *
+ * arithmetic expression evaluator
+ */
+
+/* The following only is needed for const */
+#include <ast.h>
+#include <math.h>
+#include "defs.h"
+#if _AST_VERSION >= 20030127L
+# include <ast_float.h>
+#endif
+
+#if _ast_fltmax_double
+#define LDBL_LLONG_MAX DBL_LLONG_MAX
+#define LDBL_ULLONG_MAX DBL_ULLONG_MAX
+#define LDBL_LLONG_MIN DBL_LLONG_MIN
+#endif
+
+#ifndef LDBL_LLONG_MAX
+# ifdef LLONG_MAX
+# define LDBL_LLONG_MAX ((Sfdouble_t)LLONG_MAX)
+# else
+# ifdef LLONG_MAX
+# define LDBL_LLONG_MAX ((Sfdouble_t)LLONG_MAX)
+# else
+# define LDBL_LLONG_MAX ((Sfdouble_t)((((Sflong_t)1) << (8*sizeof(Sflong_t)-1)) -1 ))
+# endif
+# endif
+#endif
+#ifndef LDBL_ULLONG_MAX
+# ifdef ULLONG_MAX
+# define LDBL_ULLONG_MAX ((Sfdouble_t)ULLONG_MAX)
+# else
+# define LDBL_ULLONG_MAX (2.*((Sfdouble_t)LDBL_LLONG_MAX))
+# endif
+#endif
+#ifndef LDBL_LLONG_MIN
+# ifdef LLONG_MIN
+# define LDBL_LLONG_MIN ((Sfdouble_t)LLONG_MIN)
+# else
+# define LDBL_LLONG_MIN (-LDBL_LLONG_MAX)
+# endif
+#endif
+#ifndef LDBL_DIG
+# define LDBL_DIG DBL_DIG
+#endif
+
+struct lval
+{
+ Shell_t *shp;
+ char *value;
+ char *ovalue;
+ Sfdouble_t (*fun)(Sfdouble_t,...);
+ const char *expr;
+ const void *ptr;
+ int nosub;
+ short flag;
+ short nargs;
+ short emode;
+ short level;
+ short elen;
+ char eflag;
+ char isfloat;
+};
+
+struct mathtab
+{
+ char fname[16];
+ Sfdouble_t (*fnptr)(Sfdouble_t,...);
+};
+
+typedef struct _arith_
+{
+ Shell_t *shp;
+ unsigned char *code;
+ const char *expr;
+ Sfdouble_t (*fun)(const char**,struct lval*,int,Sfdouble_t);
+ short size;
+ short staksize;
+ short emode;
+ short elen;
+} Arith_t;
+#define ARITH_COMP 04 /* set when compile separate from execute */
+#define ARITH_ASSIGNOP 010 /* set during assignment operators */
+
+#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_POW 9
+#define A_TIMES 10
+#define A_PLUSPLUS 11
+#define A_PLUS 12
+#define A_COMMA 13
+#define A_MINUSMINUS 14
+#define A_MINUS 15
+#define A_DIV 16
+#define A_LSHIFT 17
+#define A_LE 18
+#define A_LT 19
+#define A_EQ 20
+#define A_ASSIGN 21
+#define A_COLON 22
+#define A_RSHIFT 23
+#define A_GE 24
+#define A_GT 25
+#define A_QCOLON 26
+#define A_QUEST 27
+#define A_XOR 28
+#define A_OROR 29
+#define A_OR 30
+#define A_TILDE 31
+#define A_REG 32
+#define A_DIG 33
+#define A_INCR 34
+#define A_DECR 35
+#define A_PUSHV 36
+#define A_PUSHL 37
+#define A_PUSHN 38
+#define A_PUSHF 39
+#define A_STORE 40
+#define A_POP 41
+#define A_SWAP 42
+#define A_UMINUS 43
+#define A_JMPZ 44
+#define A_JMPNZ 45
+#define A_JMP 46
+#define A_CALL1F 47
+#define A_CALL2F 48
+#define A_CALL3F 49
+#define A_CALL1I 50
+#define A_CALL2I 51
+#define A_DOT 52
+#define A_LIT 53
+#define A_NOTNOT 54
+#define A_ASSIGNOP 55
+#define A_ENUM 56
+#define A_ASSIGNOP1 57
+
+
+/* define error messages */
+extern const unsigned char strval_precedence[35];
+extern const char strval_states[64];
+extern const char e_moretokens[];
+extern const char e_argcount[];
+extern const char e_paren[];
+extern const char e_badnum[];
+extern const char e_badcolon[];
+extern const char e_recursive[];
+extern const char e_divzero[];
+extern const char e_synbad[];
+extern const char e_notlvalue[];
+extern const char e_function[];
+extern const char e_questcolon[];
+extern const char e_incompatible[];
+extern const char e_domain[];
+extern const char e_overflow[];
+extern const char e_singularity[];
+extern const char e_dict[];
+extern const char e_charconst[];
+extern const struct mathtab shtab_math[];
+
+/* function code for the convert function */
+
+#define LOOKUP 0
+#define ASSIGN 1
+#define VALUE 2
+#define MESSAGE 3
+
+extern Sfdouble_t strval(Shell_t*,const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
+extern Arith_t *arith_compile(Shell_t *,const char*,char**,Sfdouble_t(*)(const char**,struct lval*,int,Sfdouble_t),int);
+extern Sfdouble_t arith_exec(Arith_t*);
+#endif /* !SEQPOINT */
diff --git a/src/cmd/ksh93/include/terminal.h b/src/cmd/ksh93/include/terminal.h
new file mode 100644
index 0000000..4999ca3
--- /dev/null
+++ b/src/cmd/ksh93/include/terminal.h
@@ -0,0 +1,195 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef _terminal_
+#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
+# 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)
+# 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
+# undef tcgetattr
+# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
+# undef tcsetattr
+# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
+# undef cfgetospeed
+# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
+# endif /* _lib_tcgetattr */
+# undef TIOCGETC
+# if 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 int tty_alt(int);
+extern void tty_cooked(int);
+extern int tty_get(int,struct termios*);
+extern int tty_raw(int,int);
+extern int tty_check(int);
+extern int tty_set(int, int, struct termios*);
+
+#endif /* _terminal_ */
diff --git a/src/cmd/ksh93/include/test.h b/src/cmd/ksh93/include/test.h
new file mode 100644
index 0000000..a9ed37b
--- /dev/null
+++ b/src/cmd/ksh93/include/test.h
@@ -0,0 +1,72 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef TEST_ARITH
+/*
+ * UNIX shell
+ * David Korn
+ * AT&T Labs
+ *
+ */
+
+#include "FEATURE/options"
+#include "defs.h"
+#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 16
+#define TEST_SGT 17
+#define TEST_END 8
+#define TEST_REP 20
+
+extern int test_unop(Shell_t*,int, const char*);
+extern int test_inode(const char*, const char*);
+extern int test_binop(Shell_t*,int, const char*, const char*);
+
+extern const char sh_opttest[];
+extern const char test_opchars[];
+extern const char e_argument[];
+extern const char e_missing[];
+extern const char e_badop[];
+extern const char e_tstbegin[];
+extern const char e_tstend[];
+
+#endif /* TEST_ARITH */
diff --git a/src/cmd/ksh93/include/timeout.h b/src/cmd/ksh93/include/timeout.h
new file mode 100644
index 0000000..a12c752
--- /dev/null
+++ b/src/cmd/ksh93/include/timeout.h
@@ -0,0 +1,30 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+/*
+ * UNIX shell
+ *
+ * AT&T Labs
+ *
+ */
+
+#define TGRACE 60 /* grace period before termination */
+ /* The time_warn message contains this number */
+extern const char e_timeout[];
+extern const char e_timewarn[];
diff --git a/src/cmd/ksh93/include/ulimit.h b/src/cmd/ksh93/include/ulimit.h
new file mode 100644
index 0000000..a0e6330
--- /dev/null
+++ b/src/cmd/ksh93/include/ulimit.h
@@ -0,0 +1,174 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+#ifndef _ULIMIT_H
+#define _ULIMIT_H 1
+/*
+ * This is for the ulimit built-in command
+ */
+
+#include "FEATURE/time"
+#include "FEATURE/rlimits"
+#if defined(_sys_resource) && defined(_lib_getrlimit)
+# 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 ((rlim_t)-1L)
+# endif /* INFINITY */
+#endif /* RLIM_INFINITY */
+
+#if defined(_lib_getrlimit) || defined(_lib_vlimit) || defined(_lib_ulimit)
+# ifndef RLIMIT_VMEM
+# ifdef RLIMIT_AS
+# define RLIMIT_VMEM RLIMIT_AS
+# endif
+# endif /* !RLIMIT_VMEM */
+#else
+# define _no_ulimit
+#endif
+#ifndef _typ_rlim_t
+ typedef long rlim_t;
+#endif
+
+#if !defined(RLIMIT_NOFILE) && defined(RLIMIT_OFILE)
+#define RLIMIT_NOFILE RLIMIT_OFILE
+#endif
+
+#ifndef RLIMIT_UNKNOWN
+#define RLIMIT_UNKNOWN (-9999)
+#endif
+#ifndef RLIMIT_AS
+#define RLIMIT_AS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_CORE
+#define RLIMIT_CORE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_CPU
+#define RLIMIT_CPU RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_DATA
+#define RLIMIT_DATA RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_FSIZE
+#define RLIMIT_FSIZE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_LOCKS
+#define RLIMIT_LOCKS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_MEMLOCK
+#define RLIMIT_MEMLOCK RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_MSGQUEUE
+#define RLIMIT_MSGQUEUE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_NOFILE
+#define RLIMIT_NOFILE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_NICE
+#define RLIMIT_NICE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_NPROC
+#define RLIMIT_NPROC RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_PIPE
+#define RLIMIT_PIPE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_PTHREAD
+#define RLIMIT_PTHREAD RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_RSS
+#define RLIMIT_RSS RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_RTPRIO
+#define RLIMIT_RTPRIO RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_SBSIZE
+#define RLIMIT_SBSIZE RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_SIGPENDING
+#define RLIMIT_SIGPENDING RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_STACK
+#define RLIMIT_STACK RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_SWAP
+#define RLIMIT_SWAP RLIMIT_UNKNOWN
+#endif
+#ifndef RLIMIT_VMEM
+#define RLIMIT_VMEM RLIMIT_UNKNOWN
+#endif
+
+#define LIM_COUNT 0
+#define LIM_BLOCK 1
+#define LIM_BYTE 2
+#define LIM_KBYTE 3
+#define LIM_SECOND 4
+
+typedef struct Limit_s
+{
+ const char name[16];
+ const char* description;
+ int index;
+ const char* conf;
+ unsigned char option;
+ unsigned char type;
+} Limit_t;
+
+extern const Limit_t shtab_limits[];
+extern const int shtab_units[];
+
+extern const char e_unlimited[];
+extern const char* e_units[];
+
+#endif /* _ULIMIT_H */
diff --git a/src/cmd/ksh93/include/variables.h b/src/cmd/ksh93/include/variables.h
new file mode 100644
index 0000000..edaa865
--- /dev/null
+++ b/src/cmd/ksh93/include/variables.h
@@ -0,0 +1,111 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2011 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#pragma prototyped
+
+#ifndef SH_VALNOD
+
+#include <option.h>
+#include "FEATURE/options"
+#include "FEATURE/dynamic"
+
+/* The following defines are coordinated with data in data/variables.c */
+
+#define PATHNOD (shgd->bltin_nodes)
+#define PS1NOD (shgd->bltin_nodes+1)
+#define PS2NOD (shgd->bltin_nodes+2)
+#define IFSNOD (shgd->bltin_nodes+3)
+#define PWDNOD (shgd->bltin_nodes+4)
+#define HOME (shgd->bltin_nodes+5)
+#define MAILNOD (shgd->bltin_nodes+6)
+#define REPLYNOD (shgd->bltin_nodes+7)
+#define SHELLNOD (shgd->bltin_nodes+8)
+#define EDITNOD (shgd->bltin_nodes+9)
+#define MCHKNOD (shgd->bltin_nodes+10)
+#define RANDNOD (shgd->bltin_nodes+11)
+#define ENVNOD (shgd->bltin_nodes+12)
+#define HISTFILE (shgd->bltin_nodes+13)
+#define HISTSIZE (shgd->bltin_nodes+14)
+#define HISTEDIT (shgd->bltin_nodes+15)
+#define HISTCUR (shgd->bltin_nodes+16)
+#define FCEDNOD (shgd->bltin_nodes+17)
+#define CDPNOD (shgd->bltin_nodes+18)
+#define MAILPNOD (shgd->bltin_nodes+19)
+#define PS3NOD (shgd->bltin_nodes+20)
+#define OLDPWDNOD (shgd->bltin_nodes+21)
+#define VISINOD (shgd->bltin_nodes+22)
+#define COLUMNS (shgd->bltin_nodes+23)
+#define LINES (shgd->bltin_nodes+24)
+#define PPIDNOD (shgd->bltin_nodes+25)
+#define L_ARGNOD (shgd->bltin_nodes+26)
+#define TMOUTNOD (shgd->bltin_nodes+27)
+#define SECONDS (shgd->bltin_nodes+28)
+#define LINENO (shgd->bltin_nodes+29)
+#define OPTARGNOD (shgd->bltin_nodes+30)
+#define OPTINDNOD (shgd->bltin_nodes+31)
+#define PS4NOD (shgd->bltin_nodes+32)
+#define FPATHNOD (shgd->bltin_nodes+33)
+#define LANGNOD (shgd->bltin_nodes+34)
+#define LCALLNOD (shgd->bltin_nodes+35)
+#define LCCOLLNOD (shgd->bltin_nodes+36)
+#define LCTYPENOD (shgd->bltin_nodes+37)
+#define LCMSGNOD (shgd->bltin_nodes+38)
+#define LCNUMNOD (shgd->bltin_nodes+39)
+#define FIGNORENOD (shgd->bltin_nodes+40)
+#define VERSIONNOD (shgd->bltin_nodes+41)
+#define JOBMAXNOD (shgd->bltin_nodes+42)
+#define DOTSHNOD (shgd->bltin_nodes+43)
+#define ED_CHRNOD (shgd->bltin_nodes+44)
+#define ED_COLNOD (shgd->bltin_nodes+45)
+#define ED_TXTNOD (shgd->bltin_nodes+46)
+#define ED_MODENOD (shgd->bltin_nodes+47)
+#define SH_NAMENOD (shgd->bltin_nodes+48)
+#define SH_SUBSCRNOD (shgd->bltin_nodes+49)
+#define SH_VALNOD (shgd->bltin_nodes+50)
+#define SH_VERSIONNOD (shgd->bltin_nodes+51)
+#define SH_DOLLARNOD (shgd->bltin_nodes+52)
+#define SH_MATCHNOD (shgd->bltin_nodes+53)
+#define SH_COMMANDNOD (shgd->bltin_nodes+54)
+#define SH_PATHNAMENOD (shgd->bltin_nodes+55)
+#define SH_FUNNAMENOD (shgd->bltin_nodes+56)
+#define SH_SUBSHELLNOD (shgd->bltin_nodes+57)
+#define SH_LEVELNOD (shgd->bltin_nodes+58)
+#define SH_LINENO (shgd->bltin_nodes+59)
+#define SH_STATS (shgd->bltin_nodes+60)
+#define SH_MATHNOD (shgd->bltin_nodes+61)
+#define SH_JOBPOOL (shgd->bltin_nodes+62)
+#define SHLVL (shgd->bltin_nodes+63)
+#if SHOPT_FS_3D
+# define VPATHNOD (shgd->bltin_nodes+64)
+# define NFS_3D 1
+#else
+# define NFS_3D 0
+#endif /* SHOPT_FS_3D */
+#if SHOPT_VPIX
+# define DOSPATHNOD (shgd->bltin_nodes+64+NFS_3D)
+# define VPIXNOD (shgd->bltin_nodes+65+NFS_3D)
+# define NVPIX (NFS_3D+2)
+#else
+# define NVPIX NFS_3D
+#endif /* SHOPT_VPIX */
+#ifdef apollo
+# define SYSTYPENOD (shgd->bltin_nodes+63+NVPIX)
+#endif /* apollo */
+
+#endif /* SH_VALNOD */
diff --git a/src/cmd/ksh93/include/version.h b/src/cmd/ksh93/include/version.h
new file mode 100644
index 0000000..5b2bc90
--- /dev/null
+++ b/src/cmd/ksh93/include/version.h
@@ -0,0 +1,20 @@
+/***********************************************************************
+* *
+* This software is part of the ast package *
+* Copyright (c) 1982-2012 AT&T Intellectual Property *
+* and is licensed under the *
+* Eclipse Public License, Version 1.0 *
+* by AT&T Intellectual Property *
+* *
+* A copy of the License is available at *
+* http://www.eclipse.org/org/documents/epl-v10.html *
+* (with md5 checksum b35adb5213ca9657e911e9befb180842) *
+* *
+* Information and Software Systems Research *
+* AT&T Research *
+* Florham Park NJ *
+* *
+* David Korn <dgk@research.att.com> *
+* *
+***********************************************************************/
+#define SH_RELEASE "93u+ 2012-02-29"