pgas mentioned ksh93 does [[ $foo ]] (ipv forced [[ -n $foo ]])
and it actually REDUCES code size to allow it as well; mention in the manpage that it’s merely unportable (and of course exe- cution time differs); sync clog
This commit is contained in:
parent
b051f52dd4
commit
9179c10119
94
check.t
94
check.t
@ -1,4 +1,4 @@
|
|||||||
# $MirOS: src/bin/mksh/check.t,v 1.278 2009/05/20 10:10:00 tg Exp $
|
# $MirOS: src/bin/mksh/check.t,v 1.279 2009/05/21 14:28:32 tg Exp $
|
||||||
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas 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: 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 $
|
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
|
||||||
@ -25,7 +25,7 @@
|
|||||||
# http://www.research.att.com/~gsf/public/ifs.sh
|
# http://www.research.att.com/~gsf/public/ifs.sh
|
||||||
|
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
@(#)MIRBSD KSH R38 2009/05/19
|
@(#)MIRBSD KSH R38 2009/05/21
|
||||||
description:
|
description:
|
||||||
Check version of shell.
|
Check version of shell.
|
||||||
stdin:
|
stdin:
|
||||||
@ -5632,3 +5632,93 @@ stdin:
|
|||||||
expected-stdout:
|
expected-stdout:
|
||||||
yes
|
yes
|
||||||
---
|
---
|
||||||
|
name: test-stnze-1
|
||||||
|
description:
|
||||||
|
Check that the short form [ $x ] works
|
||||||
|
stdin:
|
||||||
|
i=0
|
||||||
|
[ -n $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ -n "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
x=0
|
||||||
|
[ -n $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ -n "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
x='1 -a 1 = 2'
|
||||||
|
[ -n $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ $x ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ -n "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[ "$x" ]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
expected-stdout:
|
||||||
|
1 0
|
||||||
|
2 1
|
||||||
|
3 1
|
||||||
|
4 1
|
||||||
|
5 0
|
||||||
|
6 0
|
||||||
|
7 0
|
||||||
|
8 0
|
||||||
|
9 1
|
||||||
|
10 1
|
||||||
|
11 0
|
||||||
|
12 0
|
||||||
|
---
|
||||||
|
name: test-stnze-2
|
||||||
|
description:
|
||||||
|
Check that the short form [[ $x ]] works (ksh93 extension)
|
||||||
|
stdin:
|
||||||
|
i=0
|
||||||
|
[[ -n $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ -n "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
x=0
|
||||||
|
[[ -n $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ -n "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
x='1 -a 1 = 2'
|
||||||
|
[[ -n $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ $x ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ -n "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
[[ "$x" ]]
|
||||||
|
rv=$?; echo $((++i)) $rv
|
||||||
|
expected-stdout:
|
||||||
|
1 1
|
||||||
|
2 1
|
||||||
|
3 1
|
||||||
|
4 1
|
||||||
|
5 0
|
||||||
|
6 0
|
||||||
|
7 0
|
||||||
|
8 0
|
||||||
|
9 0
|
||||||
|
10 0
|
||||||
|
11 0
|
||||||
|
12 0
|
||||||
|
---
|
||||||
|
6
funcs.c
6
funcs.c
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include "sh.h"
|
#include "sh.h"
|
||||||
|
|
||||||
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.108 2009/05/20 10:10:01 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/funcs.c,v 1.109 2009/05/21 14:28:33 tg Exp $");
|
||||||
|
|
||||||
/* A leading = means assignments before command are kept;
|
/* A leading = means assignments before command are kept;
|
||||||
* a leading * means a POSIX special builtin;
|
* a leading * means a POSIX special builtin;
|
||||||
@ -2825,10 +2825,6 @@ test_primary(Test_env *te, bool do_eval)
|
|||||||
|
|
||||||
return (*te->eval)(te, op, opnd1, opnd2, do_eval);
|
return (*te->eval)(te, op, opnd1, opnd2, do_eval);
|
||||||
}
|
}
|
||||||
if (te->flags & TEF_DBRACKET) {
|
|
||||||
(*te->error)(te, -1, "missing expression operator");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return (*te->eval)(te, TO_STNZE, opnd1, NULL, do_eval);
|
return (*te->eval)(te, TO_STNZE, opnd1, NULL, do_eval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
8
mksh.1
8
mksh.1
@ -1,4 +1,4 @@
|
|||||||
.\" $MirOS: src/bin/mksh/mksh.1,v 1.166 2009/05/16 18:40:08 tg Exp $
|
.\" $MirOS: src/bin/mksh/mksh.1,v 1.167 2009/05/21 14:28:34 tg Exp $
|
||||||
.\" $OpenBSD: ksh.1,v 1.128 2009/03/06 12:28:36 jmc Exp $
|
.\" $OpenBSD: ksh.1,v 1.128 2009/03/06 12:28:36 jmc Exp $
|
||||||
.\"-
|
.\"-
|
||||||
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
.\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
|
||||||
@ -48,7 +48,7 @@
|
|||||||
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
|
.el .xD \\$1 \\$2 \\$3 \\$4 \\$5 \\$6 \\$7 \\$8
|
||||||
..
|
..
|
||||||
.\"-
|
.\"-
|
||||||
.Dd $Mdocdate: May 16 2009 $
|
.Dd $Mdocdate: May 21 2009 $
|
||||||
.Dt MKSH 1
|
.Dt MKSH 1
|
||||||
.Os MirBSD
|
.Os MirBSD
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -794,8 +794,8 @@ succeeds).
|
|||||||
.It
|
.It
|
||||||
The single argument form of
|
The single argument form of
|
||||||
.Ic test ,
|
.Ic test ,
|
||||||
which tests if the argument has a non-zero length, is not valid; explicit
|
which tests if the argument has a non-zero length, is not portable,
|
||||||
operators must always be used, e.g. instead of
|
e.g. instead of
|
||||||
.No \&[ Ar str No \&]
|
.No \&[ Ar str No \&]
|
||||||
use
|
use
|
||||||
.No \&[[ \-n Ar str No \&]] .
|
.No \&[[ \-n Ar str No \&]] .
|
||||||
|
4
sh.h
4
sh.h
@ -122,9 +122,9 @@
|
|||||||
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
#define __SCCSID(x) __IDSTRING(sccsid,x)
|
||||||
|
|
||||||
#ifdef EXTERN
|
#ifdef EXTERN
|
||||||
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.301 2009/05/20 10:10:02 tg Exp $");
|
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.302 2009/05/21 14:28:35 tg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#define MKSH_VERSION "R38 2009/05/19"
|
#define MKSH_VERSION "R38 2009/05/21"
|
||||||
|
|
||||||
#ifndef MKSH_INCLUDES_ONLY
|
#ifndef MKSH_INCLUDES_ONLY
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user