documentation and test suite for tonight’s new features, ☾ gn8

This commit is contained in:
tg 2009-08-28 22:46:21 +00:00
parent a1778257fe
commit 09abc55150
3 changed files with 87 additions and 5 deletions

67
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.300 2009/08/28 21:35:42 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.301 2009/08/28 22:46:19 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 $
@ -25,7 +25,7 @@
# http://www.research.att.com/~gsf/public/ifs.sh
expected-stdout:
@(#)MIRBSD KSH R39 2009/08/08
@(#)MIRBSD KSH R39 2009/08/28
description:
Check version of shell.
stdin:
@ -4943,6 +4943,69 @@ expected-stdout:
a b c d e
f g a b c d e f
---
name: arrays-4
description:
Check if Korn Shell arrays with specified indices work as expected
stdin:
v="c d"
set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
expected-stdout:
5|a|$v|c d||$v|b|
---
name: arrays-5
description:
Check if bash-style arrays with specified indices work as expected
stdin:
v="c d"
foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
expected-stdout:
5|a|$v|c d||$v|b|
---
name: arrays-6
description:
Check if we can get the array keys (indices) for indexed arrays,
Korn shell style
stdin:
of() {
i=0
for x in "$@"; do
echo -n "$((i++))<$x>"
done
echo
}
foo[1]=eins
set | grep '^foo'
echo =
foo[0]=zwei
foo[4]=drei
set | grep '^foo'
echo =
echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
expected-stdout:
foo[1]=eins
=
foo[0]=zwei
foo[1]=eins
foo[4]=drei
=
a 0<zwei>1<eins>2<drei> = a
b 0<zwei eins drei> = 0<> b
c 0<zwei>1<eins>2<drei> = c
d 0<zwei>1<eins>2<drei> = d
e 0<0>1<1>2<4> = e
f 0<0 1 4> = 0<> f
g 0<0>1<1>2<4> = g
h 0<0>1<1>2<4> = h
---
name: varexpand-substr-1
description:
Check if bash-style substring expansion works

21
mksh.1
View File

@ -1,4 +1,4 @@
.\" $MirOS: src/bin/mksh/mksh.1,v 1.176 2009/08/28 21:51:52 tg Exp $
.\" $MirOS: src/bin/mksh/mksh.1,v 1.177 2009/08/28 22:46:20 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
@ -1260,6 +1260,11 @@ of the string value of parameter
The number of elements in the array
.Ar name .
.Pp
.It Pf ${! Ns Ar name Ns [*]}
.It Pf ${! Ns Ar name Ns [@]}
The names of indices (keys) in the array
.Ar name .
.Pp
.Sm off
.It Xo
.Pf ${ Ar name
@ -3472,6 +3477,20 @@ and also supported by
.Nm ksh93
is:
.Ic foo=(a b c)
.Pp
Another
.At
.Nm ksh93
and
.Tn GNU
.Nm bash
extension allows specifying the indices used for
.Ar arg ...
.Pq from the above example, Ic a b c
like this:
.Ic set \-A foo \-\- [0]=a [1]=b [2]=c
or
.Ic foo=([0]=a [1]=b [2]=c)
.It Fl a \*(Ba Ic allexport
All new parameters are created with the export attribute.
.It Fl b \*(Ba Ic notify

4
sh.h
View File

@ -134,9 +134,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.333 2009/08/28 22:23:34 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.334 2009/08/28 22:46:21 tg Exp $");
#endif
#define MKSH_VERSION "R39 2009/08/08"
#define MKSH_VERSION "R39 2009/08/28"
#ifndef MKSH_INCLUDES_ONLY