summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/ksh/Makefile4
-rw-r--r--bin/ksh/c_ksh.c8
-rw-r--r--bin/ksh/c_sh.c14
-rw-r--r--bin/ksh/edit.c6
-rw-r--r--bin/ksh/emacs.c4
-rw-r--r--bin/ksh/exec.c8
-rw-r--r--bin/ksh/lex.c4
-rw-r--r--bin/ksh/misc.c56
-rw-r--r--bin/ksh/sh.h4
-rw-r--r--bin/ksh/table.c4
-rw-r--r--bin/ksh/table.h4
-rw-r--r--bin/ksh/var.c20
12 files changed, 66 insertions, 70 deletions
diff --git a/bin/ksh/Makefile b/bin/ksh/Makefile
index 0e356cf1337..64a36668b7c 100644
--- a/bin/ksh/Makefile
+++ b/bin/ksh/Makefile
@@ -1,4 +1,4 @@
-# $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 \
@@ -6,7 +6,7 @@ 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
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index ac10540be21..c762b22272e 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $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_*
@@ -941,8 +941,8 @@ c_alias(char **wp)
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;
@@ -1184,7 +1184,7 @@ c_kill(char **wp)
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,
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index 155b1c5ff33..6adacef4010 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $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
@@ -200,7 +200,7 @@ c_dot(char **wp)
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;
@@ -250,7 +250,7 @@ int
c_read(char **wp)
{
int c = 0;
- int expand = 1, history = 0;
+ int expand = 1, savehist = 0;
int expanding;
int ecode = 0;
char *cp;
@@ -274,7 +274,7 @@ c_read(char **wp)
expand = 0;
break;
case 's':
- history = 1;
+ savehist = 1;
break;
case 'u':
if (!*(cp = builtin_opt.optarg))
@@ -320,7 +320,7 @@ c_read(char **wp)
* coproc_readw_close(fd);
*/
- if (history)
+ if (savehist)
Xinit(xs, xp, 128, ATEMP);
expanding = 0;
Xinit(cs, cp, 128, ATEMP);
@@ -348,7 +348,7 @@ c_read(char **wp)
}
break;
}
- if (history) {
+ if (savehist) {
Xcheck(xs, xp);
Xput(xs, xp, c);
}
@@ -404,7 +404,7 @@ c_read(char **wp)
}
shf_flush(shf);
- if (history) {
+ if (savehist) {
Xput(xs, xp, '\0');
source->line++;
histsave(source->line, Xstring(xs, xp), 1);
diff --git a/bin/ksh/edit.c b/bin/ksh/edit.c
index fb85f9ff7f0..115091b179f 100644
--- a/bin/ksh/edit.c
+++ b/bin/ksh/edit.c
@@ -1,4 +1,4 @@
-/* $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
@@ -229,7 +229,7 @@ set_editmode(const char *ed)
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;
}
@@ -459,7 +459,7 @@ x_command_glob(int flags, const char *str, int slen, char ***wordsp)
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);
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index a990e12ddf9..a3afaa7c09a 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $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
@@ -1995,8 +1995,6 @@ x_prev_histword(int c)
rcp++;
x_ins(rcp);
} else {
- int c;
-
rcp = cp;
/*
* ignore white-space at start of line
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index 054f8f3e7cc..09484b8cf75 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $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
@@ -707,7 +707,7 @@ scriptexec(struct op *tp, char **ap)
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;
@@ -900,8 +900,8 @@ findcom(const char *name, int flags)
}
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;
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index 858eb898cbf..25799420068 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $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
@@ -1446,8 +1446,6 @@ dopprompt(const char *sp, int ntruncate, const char **spp, int doprint)
else if (*++cp == '!')
c = *cp++;
else {
- char *p;
-
shf_snprintf(p = nbuf, sizeof(nbuf), "%d",
source->line + 1);
len = strlen(nbuf);
diff --git a/bin/ksh/misc.c b/bin/ksh/misc.c
index c1a6006b8d0..e0fdd4a1ca9 100644
--- a/bin/ksh/misc.c
+++ b/bin/ksh/misc.c
@@ -1,4 +1,4 @@
-/* $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
@@ -115,7 +115,7 @@ Xcheck_grow_(XString *xsp, char *xp, int more)
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.
@@ -183,8 +183,8 @@ option(const char *n)
{
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;
@@ -195,7 +195,7 @@ struct options_info {
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);
@@ -225,10 +225,10 @@ printoptions(int verbose)
/* 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;
@@ -239,11 +239,11 @@ printoptions(int verbose)
} 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");
}
@@ -256,9 +256,9 @@ getoptions(void)
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);
}
@@ -328,8 +328,8 @@ parse_args(char **argv,
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;
@@ -345,12 +345,12 @@ parse_args(char **argv,
/* 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';
@@ -395,7 +395,7 @@ parse_args(char **argv,
* 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);
@@ -412,14 +412,14 @@ parse_args(char **argv,
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 */
}
diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h
index 06e7b0ec938..53d7ed6ef24 100644
--- a/bin/ksh/sh.h
+++ b/bin/ksh/sh.h
@@ -1,4 +1,4 @@
-/* $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
@@ -124,7 +124,7 @@ struct option {
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[]))
diff --git a/bin/ksh/table.c b/bin/ksh/table.c
index 074fc13ddea..d93ecddb9f2 100644
--- a/bin/ksh/table.c
+++ b/bin/ksh/table.c
@@ -1,4 +1,4 @@
-/* $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
@@ -18,7 +18,7 @@ struct table aliases; /* aliases */
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;
diff --git a/bin/ksh/table.h b/bin/ksh/table.h
index 107790d3ce2..063ae8f9534 100644
--- a/bin/ksh/table.h
+++ b/bin/ksh/table.h
@@ -1,4 +1,4 @@
-/* $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 $ */
@@ -175,7 +175,7 @@ extern const struct builtin shbuiltins [], kshbuiltins [];
#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;
diff --git a/bin/ksh/var.c b/bin/ksh/var.c
index 16805460d87..73d894897ff 100644
--- a/bin/ksh/var.c
+++ b/bin/ksh/var.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -525,11 +525,11 @@ formatstr(struct tbl *vp, const char *s)
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;
@@ -960,8 +960,8 @@ setspec(struct tbl *vp)
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:
@@ -1067,8 +1067,8 @@ unsetspec(struct tbl *vp)
{
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: