Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Import pdksh V5.2.14.

Includes lots of bugfixes.
  • Loading branch information...
commit be24f452b0991e5cc7d3de0516bbd162fa078c76 1 parent b6a11e1
hubertf authored
View
20 bin/ksh/proto.h
@@ -1,7 +1,7 @@
/*
* prototypes for PD-KSH
* originally generated using "cproto.c 3.5 92/04/11 19:28:01 cthuang "
- * $Id: proto.h,v 1.1.1.2 1996/12/18 04:50:31 jtc Exp $
+ * $Id: proto.h,v 1.1.1.3 1999/10/20 14:27:32 hubertf Exp $
*/
/* alloc.c */
@@ -43,6 +43,7 @@ int c_unset ARGS((char **wp));
int c_ulimit ARGS((char **wp));
int c_times ARGS((char **wp));
int timex ARGS((struct op *t, int f));
+void timex_hook ARGS((struct op *t, char ** volatile *app));
int c_exec ARGS((char **wp));
int c_builtin ARGS((char **wp));
/* c_test.c */
@@ -88,7 +89,7 @@ int c_fc ARGS((register char **wp));
void sethistsize ARGS((int n));
void sethistfile ARGS((const char *name));
# ifdef EASY_HISTORY
-void histappend ARGS((const char *cmd, int nl_seperate));
+void histappend ARGS((const char *cmd, int nl_separate));
# endif
char ** histpos ARGS((void));
int histN ARGS((void));
@@ -110,6 +111,12 @@ void shellf ARGS((const char *fmt, ...))
GCC_FUNC_ATTR(format(printf, 1, 2));
void shprintf ARGS((const char *fmt, ...))
GCC_FUNC_ATTR(format(printf, 1, 2));
+#ifdef KSH_DEBUG
+void kshdebug_init_ ARGS((void));
+void kshdebug_printf_ ARGS((const char *fmt, ...))
+ GCC_FUNC_ATTR(format(printf, 1, 2));
+void kshdebug_dump_ ARGS((const char *str, const void *mem, int nbytes));
+#endif /* KSH_DEBUG */
int can_seek ARGS((int fd));
void initio ARGS((void));
int ksh_dup2 ARGS((int ofd, int nfd, int errok));
@@ -126,7 +133,7 @@ void coproc_write_close ARGS((int fd));
int coproc_getfd ARGS((int mode, const char **emsgp));
void coproc_cleanup ARGS((int reuse));
#endif /* KSH */
-struct temp *maketemp ARGS((Area *ap));
+struct temp *maketemp ARGS((Area *ap, Temp_type type, struct temp **tlist));
/* jobs.c */
void j_init ARGS((int mflagset));
void j_exit ARGS((void));
@@ -151,6 +158,7 @@ void pprompt ARGS((const char *cp, int ntruncate));
/* mail.c */
#ifdef KSH
void mcheck ARGS((void));
+void mcset ARGS((long interval));
void mbset ARGS((char *p));
void mpset ARGS((char *mptoparse));
#endif /* KSH */
@@ -220,7 +228,7 @@ void inittraps ARGS((void));
#ifdef KSH
void alarm_init ARGS((void));
#endif /* KSH */
-Trap * gettrap ARGS((const char *name));
+Trap * gettrap ARGS((const char *name, int igncase));
RETSIGTYPE trapsig ARGS((int i));
void intrcheck ARGS((void));
int fatal_trap_check ARGS((void));
@@ -240,6 +248,7 @@ char * snptreef ARGS((char *s, int n, const char *fmt, ...));
struct op * tcopy ARGS((struct op *t, Area *ap));
char * wdcopy ARGS((const char *wp, Area *ap));
char * wdscan ARGS((const char *wp, int c));
+char * wdstrip ARGS((const char *wp));
void tfree ARGS((struct op *t, Area *ap));
/* var.c */
void newblock ARGS((void));
@@ -249,7 +258,7 @@ struct tbl * global ARGS((const char *n));
struct tbl * local ARGS((const char *n, bool_t copy));
char * str_val ARGS((struct tbl *vp));
long intval ARGS((struct tbl *vp));
-void setstr ARGS((struct tbl *vq, const char *s));
+int setstr ARGS((struct tbl *vq, const char *s, int error_ok));
struct tbl *setint_v ARGS((struct tbl *vq, struct tbl *vp));
void setint ARGS((struct tbl *vq, long n));
int getint ARGS((struct tbl *vp, long *nump));
@@ -260,6 +269,7 @@ char *skip_wdvarname ARGS((const char *s, int aok));
int is_wdvarname ARGS((const char *s, int aok));
int is_wdvarassign ARGS((const char *s));
char ** makenv ARGS((void));
+void change_random ARGS((void));
int array_ref_len ARGS((const char *cp));
char * arrayname ARGS((const char *str));
void set_array ARGS((const char *var, int reset, char **vals));
View
86 bin/ksh/sh.h
@@ -2,7 +2,7 @@
* Public Domain Bourne/Korn shell
*/
-/* $Id: sh.h,v 1.1.1.2 1996/10/09 15:12:52 jtc Exp $ */
+/* $Id: sh.h,v 1.1.1.3 1999/10/20 14:27:32 hubertf Exp $ */
#include "config.h" /* system and option configuration info */
@@ -28,6 +28,7 @@
/* just a useful subset of what stdlib.h would have */
extern char * getenv ARGS((const char *));
extern void * malloc ARGS((size_t));
+extern void * realloc ARGS((void *, size_t));
extern int free ARGS((void *));
extern int exit ARGS((int));
extern int rand ARGS((void));
@@ -203,17 +204,18 @@ typedef RETSIGTYPE (*handler_t) ARGS((int)); /* signal handler */
/* Special cases for execve(2) */
#ifdef OS2
-extern int ksh_execve(char *cmd, char **args, char **env);
+extern int ksh_execve(char *cmd, char **args, char **env, int flags);
#else /* OS2 */
# if defined(OS_ISC) && defined(_POSIX_SOURCE)
/* Kludge for ISC 3.2 (and other versions?) so programs will run correctly. */
-# define ksh_execve(p, av, ev) do { \
+# define ksh_execve(p, av, ev, flags) \
+ do { \
__setostype(0); \
execve(p, av, ev); \
__setostype(1); \
} while (0)
# else /* OS_ISC && _POSIX */
-# define ksh_execve(p, av, ev) execve(p, av, ev)
+# define ksh_execve(p, av, ev, flags) execve(p, av, ev)
# endif /* OS_ISC && _POSIX */
#endif /* OS2 */
@@ -235,8 +237,13 @@ extern int ksh_execve(char *cmd, char **args, char **env);
# define ksh_jmp_buf jmp_buf
#endif /* HAVE_SIGSETJMP */
+#ifndef HAVE_DUP2
+extern int dup2 ARGS((int, int));
+#endif /* !HAVE_DUP2 */
+
/* Find a integer type that is at least 32 bits (or die) - SIZEOF_* defined
- * by autoconf (assumes an 8 bit byte, but I'm not concerned)
+ * by autoconf (assumes an 8 bit byte, but I'm not concerned).
+ * NOTE: INT32 may end up being more than 32 bits.
*/
#if SIZEOF_INT >= 4
# define INT32 int
@@ -266,11 +273,15 @@ extern int ksh_execve(char *cmd, char **args, char **env);
# define EXTERN_DEFINED
#endif
+#ifdef OS2
+# define inDOS() (!(_emx_env & 0x200))
+#endif
+
#ifndef EXECSHELL
/* shell to exec scripts (see also $SHELL initialization in main.c) */
# ifdef OS2
-# define EXECSHELL "c:\\os2\\cmd.exe"
-# define EXECSHELL_STR "OS2_SHELL"
+# define EXECSHELL (inDOS() ? "c:\\command.com" : "c:\\os2\\cmd.exe")
+# define EXECSHELL_STR (inDOS() ? "COMSPEC" : "OS2_SHELL")
# else /* OS2 */
# define EXECSHELL "/bin/sh"
# define EXECSHELL_STR "EXECSHELL"
@@ -281,15 +292,16 @@ extern int ksh_execve(char *cmd, char **args, char **env);
* ISROOTEDPATH() means a .. as the first component is a no-op,
* ISRELPATH() means $PWD can be tacked on to get an absolute path.
*
- * OS Path ISABSPATH ISROOTEDPATH ISRELPATH
- * unix /foo yes yes no
- * unix foo no no yes
- * unix ../foo no no yes
- * os2 a:/foo yes yes no
- * os2 a:foo no no no
- * os2 /foo no yes no
- * os2 foo no no yes
- * os2 ../foo no no yes
+ * OS Path ISABSPATH ISROOTEDPATH ISRELPATH
+ * unix /foo yes yes no
+ * unix foo no no yes
+ * unix ../foo no no yes
+ * os2+cyg a:/foo yes yes no
+ * os2+cyg a:foo no no no
+ * os2+cyg /foo no yes no
+ * os2+cyg foo no no yes
+ * os2+cyg ../foo no no yes
+ * cyg //foo yes yes no
*/
#ifdef OS2
# define PATHSEP ';'
@@ -311,9 +323,15 @@ extern char *ksh_strrchr_dirsep(const char *path);
# define DIRSEP '/'
# define DIRSEPSTR "/"
# define ISDIRSEP(c) ((c) == '/')
+#ifdef __CYGWIN__
+# define ISABSPATH(s) \
+ (((s)[0] && (s)[1] == ':' && ISDIRSEP((s)[2])) || ISDIRSEP((s)[0]))
+# define ISRELPATH(s) (!(s)[0] || ((s)[1] != ':' && !ISDIRSEP((s)[0])))
+#else /* __CYGWIN__ */
# define ISABSPATH(s) ISDIRSEP((s)[0])
-# define ISROOTEDPATH(s) ISABSPATH(s)
# define ISRELPATH(s) (!ISABSPATH(s))
+#endif /* __CYGWIN__ */
+# define ISROOTEDPATH(s) ISABSPATH(s)
# define FILECHCONV(c) c
# define FILECMP(s1, s2) strcmp(s1, s2)
# define FILENCMP(s1, s2, n) strncmp(s1, s2, n)
@@ -353,6 +371,7 @@ typedef INT32 Tflag;
EXTERN const char *kshname; /* $0 */
EXTERN pid_t kshpid; /* $$, shell pid */
EXTERN pid_t procpid; /* pid of executing process */
+EXTERN int ksheuid; /* effective uid of shell */
EXTERN int exstat; /* exit status */
EXTERN int subst_exstat; /* exit status of last $(..)/`..` */
EXTERN const char *safe_prompt; /* safe prompt if PS1 substitution fails */
@@ -374,6 +393,16 @@ EXTERN Area aperm; /* permanent object space */
# include "chmem.h" /* a debugging front end for malloc et. al. */
#endif /* MEM_DEBUG */
+#ifdef KSH_DEBUG
+# define kshdebug_init() kshdebug_init_()
+# define kshdebug_printf(a) kshdebug_printf_ a
+# define kshdebug_dump(a) kshdebug_dump_ a
+#else /* KSH_DEBUG */
+# define kshdebug_init()
+# define kshdebug_printf(a)
+# define kshdebug_dump(a)
+#endif /* KSH_DEBUG */
+
/*
* parsing & execution environment
@@ -402,6 +431,7 @@ EXTERN struct env {
/* struct env.flag values */
#define EF_FUNC_PARSE BIT(0) /* function being parsed */
#define EF_BRKCONT_PASS BIT(1) /* set if E_LOOP must pass break/continue on */
+#define EF_FAKE_SIGDIE BIT(2) /* hack to get info from unwind to quitenv */
/* Do breaks/continues stop at env type e? */
#define STOP_BRKCONT(t) ((t) == E_NONE || (t) == E_PARSE \
@@ -425,7 +455,8 @@ EXTERN struct env {
#define OF_CMDLINE 0x01 /* command line */
#define OF_SET 0x02 /* set builtin */
#define OF_SPECIAL 0x04 /* a special variable changing */
-#define OF_ANY (OF_CMDLINE | OF_SET | OF_SPECIAL)
+#define OF_INTERNAL 0x08 /* set internally by shell */
+#define OF_ANY (OF_CMDLINE | OF_SET | OF_SPECIAL | OF_INTERNAL)
struct option {
const char *name; /* long name of option */
@@ -481,6 +512,7 @@ enum sh_flag {
FVIESCCOMPLETE, /* enable ESC as file name completion in command mode */
#endif
FXTRACE, /* -x: execution trace */
+ FTALKING_I, /* (internal): initial shell was interactive */
FNFLAGS /* (place holder: how many flags are there) */
};
@@ -493,18 +525,20 @@ EXTERN char space [] I__(" ");
EXTERN char newline [] I__("\n");
EXTERN char slash [] I__("/");
-/* temp/here files. the file is removed when the struct is freed */
+enum temp_type {
+ TT_HEREDOC_EXP, /* expanded heredoc */
+ TT_HIST_EDIT /* temp file used for history editing (fc -e) */
+};
+typedef enum temp_type Temp_type;
+/* temp/heredoc files. The file is removed when the struct is freed. */
struct temp {
struct temp *next;
struct shf *shf;
int pid; /* pid of process parsed here-doc */
+ Temp_type type;
char *name;
};
-/* here documents in functions are treated specially (the get removed when
- * shell exis) */
-EXTERN struct temp *func_heredocs;
-
/*
* stdio and our IO routines
*/
@@ -618,6 +652,7 @@ EXTERN int ifs0 I__(' '); /* for "$*" */
typedef struct {
int optind;
+ int uoptind;/* what user sees in $OPTIND */
char *optarg;
int flags; /* see GF_* */
int info; /* see GI_* */
@@ -626,6 +661,7 @@ typedef struct {
} Getopt;
EXTERN Getopt builtin_opt; /* for shell builtin commands */
+EXTERN Getopt user_opt; /* parsing state for getopts builtin command */
#ifdef KSH
@@ -689,6 +725,10 @@ EXTERN int x_cols I__(80); /* tty columns */
# endif /* __NeXT */
#endif /* KSH_SYSTEM_PROFILE */
+/* Used by v_evaluate() and setstr() to control action when error occurs */
+#define KSH_UNWIND_ERROR 0 /* unwind the stack (longjmp) */
+#define KSH_RETURN_ERROR 1 /* return 1/0 for success/failure */
+
#include "shf.h"
#include "table.h"
#include "tree.h"
View
7 bin/ksh/shf.h
@@ -1,7 +1,10 @@
+#ifndef SHF_H
+# define SHF_H
+
/*
* Shell file I/O routines
*/
-/* $Id: shf.h,v 1.1.1.1 1996/09/21 23:35:15 jtc Exp $ */
+/* $Id: shf.h,v 1.1.1.2 1999/10/20 14:27:32 hubertf Exp $ */
#define SHF_BSIZE 512
@@ -78,3 +81,5 @@ int shf_fprintf ARGS((struct shf *shf, const char *fmt, ...));
int shf_snprintf ARGS((char *buf, int bsize, const char *fmt, ...));
char *shf_smprintf ARGS((const char *fmt, ...));
int shf_vfprintf ARGS((struct shf *, const char *fmt, va_list args));
+
+#endif /* SHF_H */
View
19 bin/ksh/table.h
@@ -1,4 +1,4 @@
-/* $Id: table.h,v 1.1.1.2 1996/12/18 04:50:42 jtc Exp $ */
+/* $Id: table.h,v 1.1.1.3 1999/10/20 14:27:32 hubertf Exp $ */
/*
* generic hashed associative table for commands and variables.
@@ -110,8 +110,10 @@ struct block {
/*struct arg_info argi;*/
char **argv;
int argc;
+ int flags; /* see BF_* */
struct table vars; /* local variables */
struct table funs; /* local functions */
+ Getopt getopts_state;
#if 1
char * error; /* error handler */
char * exit; /* exit handler */
@@ -121,6 +123,9 @@ struct block {
struct block *next; /* enclosing block */
};
+/* Values for struct block.flags */
+#define BF_DOGETOPTS BIT(0) /* save/restore getopts state */
+
/*
* Used by twalk() and tnext() routines.
*/
@@ -162,13 +167,15 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
#define V_POSIXLY_CORRECT 14
#define V_TMOUT 15
#define V_TMPDIR 16
+#define V_LINENO 17
/* values for set_prompt() */
#define PS1 0 /* command */
#define PS2 1 /* command continuation */
-EXTERN const char *path; /* PATH value */
-EXTERN const char *def_path; /* path to use if PATH not set */
-EXTERN char *tmpdir; /* TMPDIR value */
-EXTERN const char *prompt;
-EXTERN int cur_prompt; /* PS1 or PS2 */
+EXTERN char *path; /* copy of either PATH or def_path */
+EXTERN const char *def_path; /* path to use if PATH not set */
+EXTERN char *tmpdir; /* TMPDIR value */
+EXTERN const char *prompt;
+EXTERN int cur_prompt; /* PS1 or PS2 */
+EXTERN int current_lineno; /* LINENO value */
View
17 bin/ksh/tree.h
@@ -2,7 +2,7 @@
* command trees for compile/execute
*/
-/* $Id: tree.h,v 1.1.1.1 1996/09/21 23:35:17 jtc Exp $ */
+/* $Id: tree.h,v 1.1.1.2 1999/10/20 14:27:32 hubertf Exp $ */
#define NOBLOCK ((struct op *)NULL)
#define NOWORD ((char *)NULL)
@@ -23,8 +23,10 @@ struct op {
struct op *left, *right; /* descendents */
char *str; /* word for case; identifier for for,
* select, and functions;
- * path to execute for TEXEC
+ * path to execute for TEXEC;
+ * time hook for TCOM.
*/
+ int lineno; /* TCOM/TFUNC: LINENO for this */
};
/* Tree.type values */
@@ -62,10 +64,10 @@ struct op {
#define EXPRSUB 4 /* $(()) substitution (0 terminated) */
#define OQUOTE 5 /* opening " or ' */
#define CQUOTE 6 /* closing " or ' */
-#define OSUBST 7 /* opening ${ substitution */
-#define CSUBST 8 /* closing } of above */
+#define OSUBST 7 /* opening ${ subst (followed by { or X) */
+#define CSUBST 8 /* closing } of above (followed by } or X) */
#define OPAT 9 /* open pattern: *(, @(, etc. */
-#define SPAT 10 /* seperate pattern: | */
+#define SPAT 10 /* separate pattern: | */
#define CPAT 11 /* close pattern: ) */
/*
@@ -74,8 +76,9 @@ struct op {
struct ioword {
int unit; /* unit affected */
int flag; /* action (below) */
- char *name; /* file name */
+ char *name; /* file name (unused if heredoc) */
char *delim; /* delimiter for <<,<<- */
+ char *heredoc;/* content of heredoc */
};
/* ioword.flag - type of redirection */
@@ -104,6 +107,8 @@ struct ioword {
#define XCCLOSE BIT(7) /* exchild: close close_fd in child */
#define XERROK BIT(8) /* non-zero exit ok (for set -e) */
#define XCOPROC BIT(9) /* starting a co-process */
+#define XTIME BIT(10) /* timeing TCOM command */
+#define XINTACT BIT(11) /* OS2: proc started from interactive session */
/*
* flags to control expansion of words (assumed by t->evalflags to fit
Please sign in to comment.
Something went wrong with that request. Please try again.