summaryrefslogtreecommitdiff
path: root/src/check.t
diff options
context:
space:
mode:
Diffstat (limited to 'src/check.t')
-rw-r--r--src/check.t370
1 files changed, 287 insertions, 83 deletions
diff --git a/src/check.t b/src/check.t
index d5df4cb..a750c50 100644
--- a/src/check.t
+++ b/src/check.t
@@ -1,9 +1,9 @@
-# $MirOS: src/bin/mksh/check.t,v 1.812 2019/03/01 16:17:29 tg Exp $
+# $MirOS: src/bin/mksh/check.t,v 1.838 2020/04/13 19:51:08 tg Exp $
# -*- mode: sh -*-
#-
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
# 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018,
-# 2019
+# 2019, 2020
# mirabilos <m@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
@@ -31,20 +31,29 @@
# (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
expected-stdout:
- @(#)MIRBSD KSH R57 2019/03/01
+ KSH R59 2020/04/14
description:
Check base version of full shell
stdin:
- echo ${KSH_VERSION%%' +'*}
+ vsn=${KSH_VERSION%%' +'*}
+ echo "${vsn#* }"
name: KSH_VERSION
+---
+expected-stdout:
+ @(#)MIRBSD
+description:
+ Check this identifies as legacy shell
+stdin:
+ echo "${KSH_VERSION%% *}"
+name: KSH_VERSION-modern
category: !shell:legacy-yes
---
expected-stdout:
- @(#)LEGACY KSH R57 2019/03/01
+ @(#)LEGACY
description:
- Check base version of legacy shell
+ Check this identifies as legacy shell
stdin:
- echo ${KSH_VERSION%%' +'*}
+ echo "${KSH_VERSION%% *}"
name: KSH_VERSION-legacy
category: !shell:legacy-no
---
@@ -53,6 +62,7 @@ description:
Check that the shell version tag does not include EBCDIC
category: !shell:ebcdic-yes
stdin:
+ set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 1
done
@@ -63,6 +73,7 @@ description:
Check that the shell version tag includes EBCDIC
category: !shell:ebcdic-no
stdin:
+ set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+EBCDIC' ]] && exit 0
done
@@ -73,6 +84,7 @@ description:
Check that the shell version tag does not include TEXTMODE
category: !shell:textmode-yes
stdin:
+ set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 1
done
@@ -83,6 +95,7 @@ description:
Check that the shell version tag includes TEXTMODE
category: !shell:textmode-no
stdin:
+ set -o noglob
for x in $KSH_VERSION; do
[[ $x = '+TEXTMODE' ]] && exit 0
done
@@ -178,7 +191,7 @@ stdin:
expected-stdout:
ok
expected-stderr-pattern:
- /mksh: warning: won't have full job control\nXX/
+ /ksh: warning: won't have full job control\nXX/
---
name: selftest-tty-present
description:
@@ -1392,7 +1405,7 @@ need-pass: no
# the mv command fails on Cygwin and z/OS
# Hurd aborts the testsuite (permission denied)
# QNX does not find subdir to cd into
-category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
+category: !os:cygwin,!os:gnu,!os:midipix,!os:msys,!os:nto,!os:os390,!nosymlink
file-setup: file 644 "x"
mkdir noread noread/target noread/target/subdir
ln -s noread link
@@ -1999,7 +2012,7 @@ expected-stdout:
name: eglob-bad-1
description:
Check that globbing isn't done when glob has syntax error
-category: !os:cygwin,!os:msys,!os:os2
+category: !os:cygwin,!os:midipix,!os:msys,!os:os2
file-setup: file 644 "@(a[b|)c]foo"
stdin:
echo @(a[b|)c]*
@@ -2491,7 +2504,7 @@ description:
# breaks on Mac OSX (HFS+ non-standard UTF-8 canonical decomposition)
# breaks on Cygwin 1.7 (files are now UTF-16 or something)
# breaks on QNX 6.4.1 (says RT)
-category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390
+category: !os:cygwin,!os:midipix,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390
need-pass: no
file-setup: file 644 "ac"
stdin:
@@ -2526,6 +2539,19 @@ expected-stdout:
-bc abc bbc cbc ebc
@bc
---
+name: glob-range-6
+description:
+ ksh93 fails this but POSIX probably demands it
+file-setup: file 644 "abc"
+file-setup: file 644 "cbc"
+stdin:
+ echo *b*
+ [ '*b*' = *b* ] && echo yep; echo $?
+expected-stdout:
+ abc cbc
+ 2
+expected-stderr-pattern: /.*/
+---
name: glob-word-1
description:
Check BSD word boundary matches
@@ -2721,7 +2747,7 @@ expected-stdout:
h\b
done
---
-name: heredoc-9a
+name: heredoc-9
description:
Check that here strings work.
stdin:
@@ -2736,6 +2762,19 @@ stdin:
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
+ fnord=42
+ bar="bar
+ \$fnord baz"
+ tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
+ tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
+ echo $(tr r z <<<'bar' 2>/dev/null)
+ cat <<< "$( : )aa"
+ IFS=$'\n'
+ x=(a "b c")
+ tr ac 12 <<< ${x[*]}
+ tr ac 34 <<< "${x[*]}"
+ tr ac 56 <<< ${x[@]}
+ tr ac 78 <<< "${x[@]}"
expected-stdout:
sbb
sbb
@@ -2748,54 +2787,17 @@ expected-stdout:
A sbb one B
$o$oone
onm
----
-name: heredoc-9b
-description:
- Check that a corner case of here strings works like bash
-stdin:
- fnord=42
- bar="bar
- \$fnord baz"
- tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
-expected-stdout:
- one $sabeq onm
-category: bash
----
-name: heredoc-9c
-description:
- Check that a corner case of here strings works like ksh93, zsh
-stdin:
- fnord=42
- bar="bar
- \$fnord baz"
- tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
-expected-stdout:
one
$sabeq onm
----
-name: heredoc-9d
-description:
- Check another corner case of here strings
-stdin:
- tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
-expected-stdout:
one
----
-name: heredoc-9e
-description:
- Check here string related regression with multiple iops
-stdin:
- echo $(tr r z <<<'bar' 2>/dev/null)
-expected-stdout:
baz
----
-name: heredoc-9f
-description:
- Check long here strings
-stdin:
- cat <<< "$( : )aa"
-expected-stdout:
aa
+ 1
+ b 2
+ 3
+ b 4
+ 5 b 6
+ 7 b 8
---
name: heredoc-10
description:
@@ -4981,6 +4983,17 @@ expected-stdout:
var=onetwo threefour
<onetwo threefour> .
---
+name: IFS-subst-11
+description:
+ Check leading non-whitespace after trim makes only one field
+stdin:
+ showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
+ v="foo!one!two!three"
+ IFS="!"
+ showargs x ${v:3} y
+expected-stdout:
+ <x> <> <one> <two> <three> <y> .
+---
name: IFS-arith-1
description:
http://austingroupbugs.net/view.php?id=832
@@ -6653,12 +6666,35 @@ name: regression-62
description:
Check if test -nt/-ot succeeds if second(first) file is missing.
stdin:
+ matrix() {
+ local a b c d e f g h
+ test a -nt b; a=$?
+ test b -nt a; b=$?
+ test a -ot b; c=$?
+ test b -ot a; d=$?
+ test a -nt a; e=$?
+ test b -nt b; f=$?
+ test a -ot a; g=$?
+ test b -ot b; h=$?
+ echo $1 $a $b $c $d / $e $f $g $h .
+ }
+ matrix a
:>a
- test a -nt b && echo nt OK || echo nt BAD
- test b -ot a && echo ot OK || echo ot BAD
-expected-stdout:
- nt OK
- ot OK
+ matrix b
+ sleep 2 # mtime granularity for OS/2 and FAT
+ :>b
+ matrix c
+ sleep 2
+ echo dummy >a # Debian GNU/Hurd #955270
+ matrix d
+ rm a
+ matrix e
+expected-stdout:
+ a 1 1 1 1 / 1 1 1 1 .
+ b 0 1 1 0 / 1 1 1 1 .
+ c 1 0 0 1 / 1 1 1 1 .
+ d 0 1 1 0 / 1 1 1 1 .
+ e 1 0 0 1 / 1 1 1 1 .
---
name: regression-63
description:
@@ -7118,13 +7154,13 @@ stdin:
name: exec-function-environment-1
description:
Check assignments in function calls and whether they affect
- the current execution environment (ksh93, SUSv4)
+ the current execution environment
stdin:
f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
echo x$a-$b- z$c-
expected-stdout:
y1-
- x2-3- z1-
+ x-3- z-
---
name: exec-modern-korn-shell
description:
@@ -7389,6 +7425,8 @@ expected-stdout:
name: xxx-stat-1
description:
Check that tests on files are consistent
+ (fails when run as root, unfortunately)
+category: disabled
stdin:
mkdir a
echo x >a/b
@@ -7580,7 +7618,7 @@ stdin:
showargs 18 "$a"
set -A bla
typeset bla[1]=~:~
- global gbl=~ g2=$1
+ typeset -g gbl=~ g2=$1
local lcl=~ l2=$1
readonly ro=~ r2=$1
showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2"
@@ -7761,6 +7799,32 @@ expected-stdout:
1 ok
expected-exit: 1
---
+name: exit-err-10
+description:
+ Debian #269067 (cf. regression-38 but with eval)
+arguments: !-e!
+stdin:
+ eval false || true
+ echo = $? .
+expected-stdout:
+ = 0 .
+---
+name: exit-err-11
+description:
+ Fix -e inside eval, from Martijn Dekker; expected-stdout from ksh93
+stdin:
+ "$__progname" -c 'eval '\''echo ${-//[!eh]}; false; echo phantom e'\''; echo x$?'
+ echo = $?
+ "$__progname" -ec 'eval '\''echo ${-//[!eh]}; false; echo phantom e'\''; echo x$?'
+ echo = $?
+expected-stdout:
+ h
+ phantom e
+ x0
+ = 0
+ eh
+ = 1
+---
name: exit-enoent-1
description:
SUSv4 says that the shell should exit with 126/127 in some situations
@@ -7832,11 +7896,9 @@ expected-exit: 9
---
name: exit-trap-2
description:
- Check that ERR and EXIT traps are run just like ksh93 does.
- GNU bash does not run ERtrap in ±e eval-undef but runs it
- twice (bug?) in +e eval-false, so does ksh93 (bug?), which
- also has a bug to continue execution (echoing "and out" and
- returning 0) in +e eval-undef.
+ Check that ERR and EXIT traps are run just like GNU bash does.
+ ksh93 runs ERtrap after “parameter null or not set” (which mksh
+ used to do) but (bug) continues “and out”, exit 0, in +e eval-undef.
file-setup: file 644 "x"
v=; unset v
trap 'echo EXtrap' EXIT
@@ -7920,7 +7982,6 @@ expected-stdout:
= eval-false 1 .
and run ${v?}
x: v: parameter null or not set
- ERtrap
EXtrap
= eval-undef 1 .
and run true
@@ -7942,12 +8003,12 @@ expected-stdout:
= eval-true 0 .
and run false
ERtrap
+ ERtrap
and out
EXtrap
= eval-false 0 .
and run ${v?}
x: v: parameter null or not set
- ERtrap
EXtrap
= eval-undef 1 .
and run true
@@ -8017,6 +8078,50 @@ expected-stdout:
nein
expected-stderr-pattern: !/unexpected op/
---
+name: test-str-pattern
+description:
+ Check that [[ x = $y ]] can take extglobs, like ksh93
+stdin:
+ x='a\'
+ [[ $x = a\ ]]; echo 1 $? .
+ [[ $x = a\\ ]]; echo 2 $? .
+ y='a\'
+ [[ $x = $y ]]; echo 3 $? .
+ [[ $x = "$y" ]]; echo 4 $? .
+ x='a\b'
+ y='a\b'
+ [[ $x = $y ]]; echo 5 $? .
+ [[ $x = "$y" ]]; echo 6 $? .
+ y='a\\b'
+ [[ $x = $y ]]; echo 7 $? .
+ [[ $x = "$y" ]]; echo 8 $? .
+ x='foo'
+ y='f+(o)'
+ [[ $x = $y ]]; echo 9 $? .
+ [[ $x = "$y" ]]; echo 10 $? .
+ x=$y
+ [[ $x = $y ]]; echo 11 $? .
+ [[ $x = "$y" ]]; echo 12 $? .
+ x='f+(o'
+ y=$x
+ [[ $x = $y ]]; echo 13 $? .
+ [[ $x = "$y" ]]; echo 14 $? .
+expected-stdout:
+ 1 1 .
+ 2 0 .
+ 3 0 .
+ 4 0 .
+ 5 1 .
+ 6 0 .
+ 7 0 .
+ 8 1 .
+ 9 0 .
+ 10 1 .
+ 11 1 .
+ 12 0 .
+ 13 0 .
+ 14 0 .
+---
name: test-precedence-1
description:
Check a weird precedence case (and POSIX echo)
@@ -8672,7 +8777,7 @@ description:
note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
need-pass: no
-category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
+category: !os:cygwin,!os:midipix,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
env-setup: !FOO=BAR!
stdin:
print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
@@ -9621,8 +9726,7 @@ expected-stdout:
---
name: varexpand-substr-3
description:
- Check that some things that work in bash fail.
- This is by design. Oh and vice versa, nowadays.
+ Match bash5
stdin:
export x=abcdefghi n=2
"$__progname" -c 'echo v${x:(n)}x'
@@ -9630,15 +9734,15 @@ stdin:
"$__progname" -c 'echo x${x:n}x'
"$__progname" -c 'echo y${x:}x'
"$__progname" -c 'echo z${x}x'
- # next fails only in bash
- "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
+ "$__progname" -c 'x=abcdef;y=123;echo q${x:${y:2:1}:2}q'
expected-stdout:
vcdefghix
wcdefghix
+ xcdefghix
zabcdefghix
- 0
+ qdeq
expected-stderr-pattern:
- /x:n.*bad substitution.*\n.*bad substitution/
+ /x:}.*bad substitution/
---
name: varexpand-substr-4
description:
@@ -10841,6 +10945,43 @@ stdin:
expected-stdout:
okay
---
+name: ulimit-3
+description:
+ Check that there are no duplicate limits (if this fails,
+ immediately contact with system information the developers)
+stdin:
+ [[ -z $(set | grep ^opt) ]]; mis=$?
+ set | grep ^opt | sed 's/^/unexpectedly set in environment: /'
+ opta='<used for showing all limits>'
+ optH='<used to set hard limits>'
+ optS='<used to set soft limits>'
+ ulimit -a >tmpf
+ set -o noglob
+ while IFS= read -r line; do
+ x=${line:1:1}
+ if [[ -z $x || ${#x}/${%x} != 1/1 ]]; then
+ print -r -- "weird line: $line"
+ (( mis |= 1 ))
+ continue
+ fi
+ set -- $line
+ nameref v=opt$x
+ if [[ -n $v ]]; then
+ print -r -- "duplicate -$x \"$2\" already seen as \"$v\""
+ (( mis |= 2 ))
+ fi
+ v=$2
+ done <tmpf
+ if (( mis & 2 )); then
+ echo failed
+ elif (( mis & 1 )); then
+ echo inconclusive
+ else
+ echo done
+ fi
+expected-stdout:
+ done
+---
name: redir-1
description:
Check some of the most basic invariants of I/O redirection
@@ -11201,7 +11342,7 @@ description:
(Inspired by PR 2450 on OpenBSD.) Calling
FOO=bar f
where f is a ksh style function, should not set FOO in the current
- env. If f is a Bourne style function, FOO should be set. Furthermore,
+ env. If f is a Bourne style function, (new) also not. Furthermore,
the function should receive a correct value of FOO. However, differing
from oksh, setting FOO in the function itself must change the value in
setting FOO in the function itself should not change the value in
@@ -11247,7 +11388,7 @@ stdin:
if [ $? != 0 ]; then
exit 1
fi
- if [ x$FOO != xfoo ]; then
+ if [ x$FOO != x ]; then
exit 1
fi
FOO=barbar
@@ -11262,7 +11403,7 @@ stdin:
if [ $? != 0 ]; then
exit 1
fi
- if [ x$FOO != xfoo ]; then
+ if [ x$FOO != xbarbar ]; then
exit 1
fi
---
@@ -12659,7 +12800,7 @@ stdin:
echo =14
(mypid=$$; try mypid)
echo =15
- ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
+ ) 2>&1 | sed -e 's/^[A-Za-z]://' -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
exit ${PIPESTATUS[0]}
expected-stdout:
y
@@ -13238,7 +13379,7 @@ description:
Crashed during March 2011, fixed on vernal equinōx ☺
category: os:mirbsd,os:openbsd
stdin:
- export MALLOC_OPTIONS=FGJPRSX
+ export MALLOC_OPTIONS=FGJRSX
"$__progname" -c 'x=$(tr z r <<<baz); echo $x'
expected-stdout:
bar
@@ -13362,6 +13503,59 @@ expected-stdout:
after 0='swc' 1='二' 2=''
= done
---
+name: command-set
+description:
+ Same but with set
+stdin:
+ showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
+ showargs 1 "$@"
+ set -- foo bar baz
+ showargs 2 "$@"
+ command set -- miau 'meow nyao'
+ showargs 3 "$@"
+expected-stdout:
+ <1> .
+ <2> <foo> <bar> <baz> .
+ <3> <miau> <meow nyao> .
+---
+name: command-readonly
+description:
+ These should not exit on error when prefixed
+stdin:
+ exec 2>/dev/null
+ "$__progname" -c 'readonly v; export v=foo || echo ok'
+ echo ef=$?
+ "$__progname" -c 'readonly v; command export v=foo || echo ok'
+ echo en=$?
+ "$__progname" -c 'readonly v; readonly v=foo || echo ok'
+ echo rf=$?
+ "$__progname" -c 'readonly v; command readonly v=foo || echo ok'
+ echo rn=$?
+expected-stdout:
+ ef=2
+ ok
+ en=0
+ rf=2
+ ok
+ rn=0
+---
+name: command-dot-regression
+description:
+ Check a regression in fixing the above does not appear
+stdin:
+ cat >test.mksh <<\EOF
+ set -- one two
+ shift
+ for s_arg in "$#" "$@"; do echo -n "<$s_arg> "; done; echo .
+ EOF
+ "$__progname" -c '. ./test.mksh' dummy oh dear this is not good
+ echo =
+ "$__progname" -c 'command . ./test.mksh' dummy oh dear this is not good
+expected-stdout:
+ <1> <two> .
+ =
+ <1> <two> .
+---
name: command-pvV-posix-priorities
description:
For POSIX compatibility, command -v should find aliases and reserved
@@ -13370,13 +13564,17 @@ description:
stdin:
PATH=/bin:/usr/bin
alias foo="bar baz"
+ alias '[ab]=:'
bar() { :; }
- for word in 'if' 'foo' 'bar' 'set' 'true'; do
+ for word in 'if' 'foo' 'bar' 'set' 'true' '[ab]'; do
command -v "$word"
command -pv "$word"
command -V "$word"
command -pV "$word"
done
+ # extra checks
+ alias '[ab]'
+ whence '[ab]'
expected-stdout:
if
if
@@ -13398,6 +13596,12 @@ expected-stdout:
true
true is a shell builtin
true is a shell builtin
+ alias '[ab]'=:
+ alias '[ab]'=:
+ '[ab]' is an alias for :
+ '[ab]' is an alias for :
+ '[ab]'=:
+ :
---
name: whence-preserve-tradition
description: