diff --git a/check.t b/check.t index fa20ed0..792f74c 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.351 2010/01/01 17:44:06 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.352 2010/01/01 18:01:59 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 $ @@ -4460,6 +4460,28 @@ stdin: echo 1- $(runtest utf8-mode) = echo 2- $(runtest !utf8-mode) = echo 3- $(runtest ?utf8-mode) = + echo = short flags = + echo 0y $(if_test -U) = + echo 0y $(if_test +U) = + echo 0n $(if_test -_) = + echo 0n $(if_test -U-) = + echo 1= $(runtest -_) = + echo 2= $(runtest !-_) = + echo 3= $(runtest ?-_) = + set +U + echo 1+ $(runtest -U) = + echo 2+ $(runtest !-U) = + echo 3+ $(runtest ?-U) = + echo 1+ $(runtest +U) = + echo 2+ $(runtest !+U) = + echo 3+ $(runtest ?+U) = + set -U + echo 1- $(runtest -U) = + echo 2- $(runtest !-U) = + echo 3- $(runtest ?-U) = + echo 1- $(runtest +U) = + echo 2- $(runtest !+U) = + echo 3- $(runtest ?+U) = expected-stdout: 0y 0 0 0 0 = 0n 1 1 1 1 = @@ -4472,6 +4494,26 @@ expected-stdout: 1- 0 0 0 = 2- 1 1 1 = 3- 0 0 0 = + = short flags = + 0y 0 0 0 0 = + 0y 0 0 0 0 = + 0n 1 1 1 1 = + 0n 1 1 1 1 = + 1= 1 1 1 = + 2= 1 1 1 = + 3= 1 1 1 = + 1+ 1 1 1 = + 2+ 0 0 0 = + 3+ 0 0 0 = + 1+ 1 1 1 = + 2+ 0 0 0 = + 3+ 0 0 0 = + 1- 0 0 0 = + 2- 1 1 1 = + 3- 0 0 0 = + 1- 0 0 0 = + 2- 1 1 1 = + 3- 0 0 0 = --- name: mkshrc-1 description: diff --git a/misc.c b/misc.c index 914ee7c..1c80fa7 100644 --- a/misc.c +++ b/misc.c @@ -29,7 +29,7 @@ #include #endif -__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.134 2009/12/05 17:43:48 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/misc.c,v 1.135 2010/01/01 18:02:00 tg Exp $"); unsigned char chtypes[UCHAR_MAX + 1]; /* type bits for unsigned char */ @@ -108,7 +108,11 @@ option(const char *n) { size_t i; - for (i = 0; i < NELEM(options); i++) + if ((n[0] == '-' || n[0] == '+') && n[1] && !n[2]) { + for (i = 0; i < NELEM(options); i++) + if (options[i].c == n[1]) + return (i); + } else for (i = 0; i < NELEM(options); i++) if (options[i].name && strcmp(options[i].name, n) == 0) return (i); diff --git a/mksh.1 b/mksh.1 index b0ede6f..0d86544 100644 --- a/mksh.1 +++ b/mksh.1 @@ -1,4 +1,4 @@ -.\" $MirOS: src/bin/mksh/mksh.1,v 1.203 2010/01/01 17:44:08 tg Exp $ +.\" $MirOS: src/bin/mksh/mksh.1,v 1.204 2010/01/01 18:02:01 tg Exp $ .\" $OpenBSD: ksh.1,v 1.129 2009/05/28 06:09:06 jmc Exp $ .\"- .\" Copyright © 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 @@ -3911,7 +3911,8 @@ Enable mode. Automatically enabled if the basename of the shell invocation begins with .Dq sh -and this autodetection feature was requested at compilation time. +and this autodetection feature was requested at compilation time +.Pq not in MirBSD . As a side effect, setting this flag turns off .Ic braceexpand mode, which can be turned back on manually. @@ -4061,6 +4062,18 @@ exists). The same can be achieved with [ \-o ?foo ] like in .At .Nm ksh93 . +.Ar option +can also be the short flag led by either +.Ql \- +or +.Ql + +.Pq no logical negation , +for example +.Ql \-x +or +.Ql +x +instead of +.Ql xtrace . .It Fl p Ar file .Ar file is a named pipe.