-# $OpenBSD: Makefile,v 1.34 2017/08/01 14:30:05 deraadt Exp $
+# $OpenBSD: Makefile,v 1.35 2017/12/27 13:02:57 millert Exp $
PROG= ksh
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
version.c vi.c
-DEFS= -Wall -DEMACS -DVI
+DEFS= -Wall -Wshadow -DEMACS -DVI
CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen
MAN= ksh.1 sh.1
-/* $OpenBSD: c_ksh.c,v 1.51 2017/09/03 11:52:01 jca Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.52 2017/12/27 13:02:57 millert Exp $ */
/*
* built-in Korn commands: c_*
afree(ap->val.s, APERM);
}
/* ignore values for -t (at&t ksh does this) */
- newval = tflag ? search(alias, path, X_OK, NULL) :
- val;
+ newval = tflag ? search(alias, search_path, X_OK, NULL)
+ : val;
if (newval) {
ap->val.s = str_save(newval, APERM);
ap->flag |= ALLOC|ISSET;
shprintf("%s%s", p, sigtraps[i].name);
shprintf("\n");
} else {
- int mess_width = 0, w, i;
+ int mess_width = 0, w;
struct kill_info ki = {
.num_width = 1,
.name_width = 0,
-/* $OpenBSD: c_sh.c,v 1.61 2017/12/07 01:54:33 tb Exp $ */
+/* $OpenBSD: c_sh.c,v 1.62 2017/12/27 13:02:57 millert Exp $ */
/*
* built-in Bourne commands
if ((cp = wp[builtin_opt.optind]) == NULL)
return 0;
- file = search(cp, path, R_OK, &err);
+ file = search(cp, search_path, R_OK, &err);
if (file == NULL) {
bi_errorf("%s: %s", cp, err ? strerror(err) : "not found");
return 1;
c_read(char **wp)
{
int c = 0;
- int expand = 1, history = 0;
+ int expand = 1, savehist = 0;
int expanding;
int ecode = 0;
char *cp;
expand = 0;
break;
case 's':
- history = 1;
+ savehist = 1;
break;
case 'u':
if (!*(cp = builtin_opt.optarg))
* coproc_readw_close(fd);
*/
- if (history)
+ if (savehist)
Xinit(xs, xp, 128, ATEMP);
expanding = 0;
Xinit(cs, cp, 128, ATEMP);
}
break;
}
- if (history) {
+ if (savehist) {
Xcheck(xs, xp);
Xput(xs, xp, c);
}
}
shf_flush(shf);
- if (history) {
+ if (savehist) {
Xput(xs, xp, '\0');
source->line++;
histsave(source->line, Xstring(xs, xp), 1);
-/* $OpenBSD: edit.c,v 1.57 2016/09/08 12:12:40 nicm Exp $ */
+/* $OpenBSD: edit.c,v 1.58 2017/12/27 13:02:57 millert Exp $ */
/*
* Command line editing - common code
if ((rcp = strrchr(ed, '/')))
ed = ++rcp;
for (i = 0; i < NELEM(edit_flags); i++)
- if (strstr(ed, options[(int) edit_flags[i]].name)) {
+ if (strstr(ed, sh_options[(int) edit_flags[i]].name)) {
change_flag(edit_flags[i], OF_SPECIAL, 1);
return;
}
for (l = genv->loc; l; l = l->next)
glob_table(pat, &w, &l->funs);
- glob_path(flags, pat, &w, path);
+ glob_path(flags, pat, &w, search_path);
if ((fpath = str_val(global("FPATH"))) != null)
glob_path(flags, pat, &w, fpath);
-/* $OpenBSD: emacs.c,v 1.76 2017/12/18 19:04:53 anton Exp $ */
+/* $OpenBSD: emacs.c,v 1.77 2017/12/27 13:02:57 millert Exp $ */
/*
* Emacs-like command line editing and history
rcp++;
x_ins(rcp);
} else {
- int c;
-
rcp = cp;
/*
* ignore white-space at start of line
-/* $OpenBSD: exec.c,v 1.69 2017/12/18 20:30:14 anton Exp $ */
+/* $OpenBSD: exec.c,v 1.70 2017/12/27 13:02:57 millert Exp $ */
/*
* execute command tree
shell = str_val(global("EXECSHELL"));
if (shell && *shell)
- shell = search(shell, path, X_OK, NULL);
+ shell = search(shell, search_path, X_OK, NULL);
if (!shell || !*shell)
shell = _PATH_BSHELL;
}
tp->flag = DEFINED; /* make ~ISSET */
}
- npath = search(name, flags & FC_DEFPATH ? def_path : path,
- X_OK, &tp->u2.errno_);
+ npath = search(name, flags & FC_DEFPATH ? def_path :
+ search_path, X_OK, &tp->u2.errno_);
if (npath) {
if (tp == &temp) {
tp->val.s = npath;
-/* $OpenBSD: lex.c,v 1.73 2017/12/12 00:18:58 tb Exp $ */
+/* $OpenBSD: lex.c,v 1.74 2017/12/27 13:02:57 millert Exp $ */
/*
* lexical analysis and source input
else if (*++cp == '!')
c = *cp++;
else {
- char *p;
-
shf_snprintf(p = nbuf, sizeof(nbuf), "%d",
source->line + 1);
len = strlen(nbuf);
-/* $OpenBSD: misc.c,v 1.60 2017/10/19 07:54:05 jca Exp $ */
+/* $OpenBSD: misc.c,v 1.61 2017/12/27 13:02:57 millert Exp $ */
/*
* Miscellaneous functions
return xsp->beg + (xp - old_beg);
}
-const struct option options[] = {
+const struct option sh_options[] = {
/* Special cases (see parse_args()): -A, -o, -s.
* Options are sorted by their longnames - the order of these
* entries MUST match the order of sh_flag F* enumerations in sh.h.
{
int i;
- for (i = 0; i < NELEM(options); i++)
- if (options[i].name && strcmp(options[i].name, n) == 0)
+ for (i = 0; i < NELEM(sh_options); i++)
+ if (sh_options[i].name && strcmp(sh_options[i].name, n) == 0)
return i;
return -1;
struct {
const char *name;
int flag;
- } opts[NELEM(options)];
+ } opts[NELEM(sh_options)];
};
static char *options_fmt_entry(void *arg, int i, char *buf, int buflen);
/* verbose version */
shprintf("Current option settings\n");
- for (i = n = oi.opt_width = 0; i < NELEM(options); i++) {
- if (options[i].name) {
- len = strlen(options[i].name);
- oi.opts[n].name = options[i].name;
+ for (i = n = oi.opt_width = 0; i < NELEM(sh_options); i++) {
+ if (sh_options[i].name) {
+ len = strlen(sh_options[i].name);
+ oi.opts[n].name = sh_options[i].name;
oi.opts[n++].flag = i;
if (len > oi.opt_width)
oi.opt_width = len;
} else {
/* short version ala ksh93 */
shprintf("set");
- for (i = 0; i < NELEM(options); i++) {
- if (options[i].name)
+ for (i = 0; i < NELEM(sh_options); i++) {
+ if (sh_options[i].name)
shprintf(" %co %s",
Flag(i) ? '-' : '+',
- options[i].name);
+ sh_options[i].name);
}
shprintf("\n");
}
char m[(int) FNFLAGS + 1];
char *cp = m;
- for (i = 0; i < NELEM(options); i++)
- if (options[i].c && Flag(i))
- *cp++ = options[i].c;
+ for (i = 0; i < NELEM(sh_options); i++)
+ if (sh_options[i].c && Flag(i))
+ *cp++ = sh_options[i].c;
*cp = 0;
return str_save(m, ATEMP);
}
int what, /* OF_CMDLINE or OF_SET */
int *setargsp)
{
- static char cmd_opts[NELEM(options) + 3]; /* o:\0 */
- static char set_opts[NELEM(options) + 5]; /* Ao;s\0 */
+ static char cmd_opts[NELEM(sh_options) + 3]; /* o:\0 */
+ static char set_opts[NELEM(sh_options) + 5]; /* Ao;s\0 */
char *opts;
char *array = NULL;
Getopt go;
/* see set_opts[] declaration */
strlcpy(set_opts, "A:o;s", sizeof set_opts);
q = set_opts + strlen(set_opts);
- for (i = 0; i < NELEM(options); i++) {
- if (options[i].c) {
- if (options[i].flags & OF_CMDLINE)
- *p++ = options[i].c;
- if (options[i].flags & OF_SET)
- *q++ = options[i].c;
+ for (i = 0; i < NELEM(sh_options); i++) {
+ if (sh_options[i].c) {
+ if (sh_options[i].flags & OF_CMDLINE)
+ *p++ = sh_options[i].c;
+ if (sh_options[i].flags & OF_SET)
+ *q++ = sh_options[i].c;
}
}
*p = '\0';
* if the output of "set +o" is to be used.
*/
;
- else if (i >= 0 && (options[i].flags & what))
+ else if (i >= 0 && (sh_options[i].flags & what))
change_flag((enum sh_flag) i, what, set);
else {
bi_errorf("%s: bad option", go.optarg);
sortargs = 1;
break;
}
- for (i = 0; i < NELEM(options); i++)
- if (optc == options[i].c &&
- (what & options[i].flags)) {
+ for (i = 0; i < NELEM(sh_options); i++)
+ if (optc == sh_options[i].c &&
+ (what & sh_options[i].flags)) {
change_flag((enum sh_flag) i, what,
set);
break;
}
- if (i == NELEM(options)) {
+ if (i == NELEM(sh_options)) {
internal_errorf(1, "parse_args: `%c'", optc);
return -1; /* not reached */
}
-/* $OpenBSD: sh.h,v 1.65 2017/10/19 07:54:05 jca Exp $ */
+/* $OpenBSD: sh.h,v 1.66 2017/12/27 13:02:57 millert Exp $ */
/*
* Public Domain Bourne/Korn shell
char c; /* character flag (if any) */
short flags; /* OF_* */
};
-extern const struct option options[];
+extern const struct option sh_options[];
/*
* flags (the order of these enums MUST match the order in misc.c(options[]))
-/* $OpenBSD: table.c,v 1.23 2015/11/01 15:38:53 mmcc Exp $ */
+/* $OpenBSD: table.c,v 1.24 2017/12/27 13:02:57 millert Exp $ */
/*
* dynamic hashed associative table for commands and variables
struct table keywords; /* keywords */
struct table homedirs; /* homedir() cache */
-char *path; /* copy of either PATH or def_path */
+char *search_path; /* copy of either PATH or def_path */
const char *def_path; /* path to use if PATH not set */
char *tmpdir; /* TMPDIR value */
const char *prompt;
-/* $OpenBSD: table.h,v 1.12 2017/08/30 17:08:45 jca Exp $ */
+/* $OpenBSD: table.h,v 1.13 2017/12/27 13:02:57 millert Exp $ */
/* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */
#define PS1 0 /* command */
#define PS2 1 /* command continuation */
-extern char *path; /* copy of either PATH or def_path */
+extern char *search_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;
-/* $OpenBSD: var.c,v 1.59 2017/08/30 17:08:45 jca Exp $ */
+/* $OpenBSD: var.c,v 1.60 2017/12/27 13:02:57 millert Exp $ */
#include <sys/stat.h>
int slen;
if (vp->flag & RJUST) {
- const char *q = s + olen;
- /* strip trailing spaces (at&t ksh uses q[-1] == ' ') */
- while (q > s && isspace((unsigned char)q[-1]))
- --q;
- slen = q - s;
+ const char *r = s + olen;
+ /* strip trailing spaces (at&t ksh uses r[-1] == ' ') */
+ while (r > s && isspace((unsigned char)r[-1]))
+ --r;
+ slen = r - s;
if (slen > vp->u2.field) {
s += slen - vp->u2.field;
slen = vp->u2.field;
switch (special(vp->name)) {
case V_PATH:
- afree(path, APERM);
- path = str_save(str_val(vp), APERM);
+ afree(search_path, APERM);
+ search_path = str_save(str_val(vp), APERM);
flushcom(1); /* clear tracked aliases */
break;
case V_IFS:
{
switch (special(vp->name)) {
case V_PATH:
- afree(path, APERM);
- path = str_save(def_path, APERM);
+ afree(search_path, APERM);
+ search_path = str_save(def_path, APERM);
flushcom(1); /* clear tracked aliases */
break;
case V_IFS: