use already-existing ksh_isdash helper macro

This commit is contained in:
tg 2015-04-29 18:32:44 +00:00
parent c9ccf0bab7
commit c3efd2abb2
4 changed files with 9 additions and 9 deletions

4
eval.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/eval.c,v 1.167 2015/04/11 22:03:29 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/eval.c,v 1.168 2015/04/29 18:32:42 tg Exp $");
/* /*
* string expansion * string expansion
@ -1734,7 +1734,7 @@ do_tilde(char *cp)
dp = str_val(global("HOME")); dp = str_val(global("HOME"));
else if (cp[0] == '+' && cp[1] == '\0') else if (cp[0] == '+' && cp[1] == '\0')
dp = str_val(global("PWD")); dp = str_val(global("PWD"));
else if (cp[0] == '-' && cp[1] == '\0') else if (ksh_isdash(cp))
dp = str_val(global("OLDPWD")); dp = str_val(global("OLDPWD"));
#ifndef MKSH_NOPWNAM #ifndef MKSH_NOPWNAM
else else

4
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.151 2015/04/19 14:40:08 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/exec.c,v 1.152 2015/04/29 18:32:43 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL #ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh" #define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -1382,7 +1382,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
const char *emsg; const char *emsg;
do_open = false; do_open = false;
if (*cp == '-' && !cp[1]) { if (ksh_isdash(cp)) {
/* prevent error return below */ /* prevent error return below */
u = 1009; u = 1009;
do_close = true; do_close = true;

View File

@ -38,7 +38,7 @@
#endif #endif
#endif #endif
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.268 2015/04/19 14:40:23 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.269 2015/04/29 18:32:43 tg Exp $");
#if HAVE_KILLPG #if HAVE_KILLPG
/* /*
@ -2308,7 +2308,7 @@ c_trap(const char **wp)
*/ */
/* get command */ /* get command */
s = (gettrap(*wp, false) == NULL) ? *wp++ : NULL; s = (gettrap(*wp, false) == NULL) ? *wp++ : NULL;
if (s != NULL && s[0] == '-' && s[1] == '\0') if (s != NULL && ksh_isdash(s))
s = NULL; s = NULL;
/* set/clear traps */ /* set/clear traps */
@ -3634,7 +3634,7 @@ c_cat(const char **wp)
do { do {
if (*wp) { if (*wp) {
fn = *wp++; fn = *wp++;
if (fn[0] == '-' && fn[1] == '\0') if (ksh_isdash(fn))
fd = STDIN_FILENO; fd = STDIN_FILENO;
else if ((fd = open(fn, O_RDONLY | O_BINARY)) < 0) { else if ((fd = open(fn, O_RDONLY | O_BINARY)) < 0) {
eno = errno; eno = errno;

4
misc.c
View File

@ -30,7 +30,7 @@
#include <grp.h> #include <grp.h>
#endif #endif
__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.226 2015/03/20 21:46:40 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/misc.c,v 1.227 2015/04/29 18:32:44 tg Exp $");
#define KSH_CHVT_FLAG #define KSH_CHVT_FLAG
#ifdef MKSH_SMALL #ifdef MKSH_SMALL
@ -1007,7 +1007,7 @@ ksh_getopt(const char **argv, Getopt *go, const char *optionsp)
const char *arg = argv[go->optind], flag = arg ? *arg : '\0'; const char *arg = argv[go->optind], flag = arg ? *arg : '\0';
go->p = 1; go->p = 1;
if (flag == '-' && arg[1] == '-' && arg[2] == '\0') { if (flag == '-' && ksh_isdash(arg + 1)) {
go->optind++; go->optind++;
go->p = 0; go->p = 0;
go->info |= GI_MINUSMINUS; go->info |= GI_MINUSMINUS;