ormaaj reported “command shift” not working correctly; fix
This commit is contained in:
parent
7a2130b02a
commit
2d9a039ec0
34
check.t
34
check.t
@ -1,4 +1,4 @@
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.585 2013/01/01 22:23:14 tg Exp $
|
||||
# $MirOS: src/bin/mksh/check.t,v 1.586 2013/01/06 18:51:39 tg Exp $
|
||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
|
||||
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||
@ -29,7 +29,7 @@
|
||||
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
|
||||
|
||||
expected-stdout:
|
||||
@(#)MIRBSD KSH R41 2013/01/01
|
||||
@(#)MIRBSD KSH R41 2013/01/06
|
||||
description:
|
||||
Check version of shell.
|
||||
stdin:
|
||||
@ -38,7 +38,7 @@ name: KSH_VERSION
|
||||
category: shell:legacy-no
|
||||
---
|
||||
expected-stdout:
|
||||
@(#)LEGACY KSH R41 2013/01/01
|
||||
@(#)LEGACY KSH R41 2013/01/06
|
||||
description:
|
||||
Check version of legacy shell.
|
||||
stdin:
|
||||
@ -10566,6 +10566,34 @@ expected-stdout:
|
||||
5(esac)bourne no
|
||||
6(esac)korn esac
|
||||
---
|
||||
name: command-shift
|
||||
description:
|
||||
Check that 'command shift' works
|
||||
stdin:
|
||||
function snc {
|
||||
echo "before 0='$0' 1='$1' 2='$2'"
|
||||
shift
|
||||
echo "after 0='$0' 1='$1' 2='$2'"
|
||||
}
|
||||
function swc {
|
||||
echo "before 0='$0' 1='$1' 2='$2'"
|
||||
command shift
|
||||
echo "after 0='$0' 1='$1' 2='$2'"
|
||||
}
|
||||
echo = without command
|
||||
snc 一 二
|
||||
echo = with command
|
||||
swc 一 二
|
||||
echo = done
|
||||
expected-stdout:
|
||||
= without command
|
||||
before 0='snc' 1='一' 2='二'
|
||||
after 0='snc' 1='二' 2=''
|
||||
= with command
|
||||
before 0='swc' 1='一' 2='二'
|
||||
after 0='swc' 1='二' 2=''
|
||||
= done
|
||||
---
|
||||
name: stateptr-underflow
|
||||
description:
|
||||
This check overflows an Xrestpos stored in a short in R40
|
||||
|
12
exec.c
12
exec.c
@ -23,7 +23,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.111 2013/01/01 20:45:02 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.112 2013/01/06 18:51:42 tg Exp $");
|
||||
|
||||
#ifndef MKSH_DEFAULT_EXECSHELL
|
||||
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
|
||||
@ -506,7 +506,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
/* Must be static (XXX but why?) */
|
||||
static struct op texec;
|
||||
int type_flags;
|
||||
int keepasn_ok;
|
||||
bool keepasn_ok;
|
||||
int fcflags = FC_BI|FC_FUNC|FC_PATH;
|
||||
bool bourne_function_call = false;
|
||||
struct block *l_expand, *l_assign;
|
||||
@ -538,7 +538,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
* FOO=bar command FOO is neither kept nor exported
|
||||
* PATH=... foobar use new PATH in foobar search
|
||||
*/
|
||||
keepasn_ok = 1;
|
||||
keepasn_ok = true;
|
||||
while (tp && tp->type == CSHELL) {
|
||||
/* undo effects of command */
|
||||
fcflags = FC_BI|FC_FUNC|FC_PATH;
|
||||
@ -585,7 +585,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
* POSIX says special builtins lose their status
|
||||
* if accessed using command.
|
||||
*/
|
||||
keepasn_ok = 0;
|
||||
keepasn_ok = false;
|
||||
if (!ap[0]) {
|
||||
/* ensure command with no args exits with 0 */
|
||||
subst_exstat = 0;
|
||||
@ -678,6 +678,10 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
|
||||
/* shell built-in */
|
||||
case CSHELL:
|
||||
rv = call_builtin(tp, (const char **)ap, null);
|
||||
if (!keepasn_ok && tp->val.f == c_shift) {
|
||||
l_expand->argc = l_assign->argc;
|
||||
l_expand->argv = l_assign->argv;
|
||||
}
|
||||
break;
|
||||
|
||||
/* function call */
|
||||
|
4
sh.h
4
sh.h
@ -164,9 +164,9 @@
|
||||
#endif
|
||||
|
||||
#ifdef EXTERN
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.626 2013/01/01 20:45:04 tg Exp $");
|
||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.627 2013/01/06 18:51:43 tg Exp $");
|
||||
#endif
|
||||
#define MKSH_VERSION "R41 2013/01/01"
|
||||
#define MKSH_VERSION "R41 2013/01/06"
|
||||
|
||||
/* arithmetic types: C implementation */
|
||||
#if !HAVE_CAN_INTTYPES
|
||||
|
Loading…
Reference in New Issue
Block a user