2016-01-21 18:24:45 +00:00
# $MirOS: src/bin/mksh/check.t,v 1.722 2016/01/21 18:24:35 tg Exp $
2015-01-04 20:23:51 +00:00
# -*- mode: sh -*-
2005-05-23 03:06:10 +00:00
#-
2012-01-03 00:58:09 +00:00
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2016-01-14 23:19:12 +00:00
# 2011, 2012, 2013, 2014, 2015, 2016
2015-10-05 17:59:00 +00:00
# mirabilos <m@mirbsd.org>
2009-05-16 16:59:42 +00:00
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
2009-05-16 18:40:09 +00:00
# is granted to deal in this work without restriction, including un‐
2009-05-16 16:59:42 +00:00
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
2009-05-16 18:40:09 +00:00
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
2009-05-16 16:59:42 +00:00
# the utmost extent permitted by applicable law, neither express nor
# implied; without malicious intent or gross negligence. In no event
# may a licensor, author or contributor be held liable for indirect,
# direct, other damage, loss, or other issues arising in any way out
# of dealing in the work, even if advised of the possibility of such
# damage or existence of a defect, except proven that it results out
2009-05-16 18:40:09 +00:00
# of said person’ s immediate fault when using the work as intended.
2009-05-16 16:59:42 +00:00
#-
2005-06-08 21:51:22 +00:00
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
2014-10-19 22:26:13 +00:00
#
# More testsuites at:
# http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
2015-01-04 20:23:51 +00:00
#
# Integrated testsuites from:
# (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
2005-05-23 03:06:10 +00:00
2006-11-12 10:44:42 +00:00
expected - stdout:
2016-01-21 18:24:45 +00:00
@ ( # ) MIRBSD KSH R52 2016 /01/ 21
2006-11-12 10:44:42 +00:00
description:
Check version of shell .
stdin:
echo $ KSH_VERSION
name: KSH_VERSION
2012-06-25 16:05:10 +00:00
category: shell:legacy - no
- - -
expected - stdout:
2016-01-21 18:24:45 +00:00
@ ( # ) LEGACY KSH R52 2016 /01/ 21
2012-06-25 16:05:10 +00:00
description:
Check version of legacy shell .
stdin:
echo $ KSH_VERSION
name: KSH_VERSION - legacy
category: shell:legacy - yes
2006-11-12 10:44:42 +00:00
- - -
2008-03-23 20:43:51 +00:00
name: selftest - 1
description:
Regression test self - testing
stdin:
2009-10-02 18:08:37 +00:00
echo $ { foo: - baz }
2008-03-23 20:43:51 +00:00
expected - stdout:
baz
- - -
name: selftest - 2
description:
Regression test self - testing
env - setup: ! foo = bar !
stdin:
2009-10-02 18:08:37 +00:00
echo $ { foo: - baz }
2008-03-23 20:43:51 +00:00
expected - stdout:
bar
- - -
name: selftest - 3
description:
Regression test self - testing
env - setup: ! ENV = fnord !
stdin:
2009-10-02 18:08:37 +00:00
echo "<$ENV>"
2008-03-23 20:43:51 +00:00
expected - stdout:
<fnord>
- - -
2014-02-08 20:20:32 +00:00
name: selftest - exec
description:
Ensure that the test run directory ( default / tmp but can be changed
with check . pl flag - T or test . sh $ TMPDIR ) is not mounted noexec , as
we execute scripts from the scratch directory during several tests .
stdin:
print '#!' "$__progname" '\necho tf' > lq
chmod + x lq
. / lq
expected - stdout:
tf
- - -
2008-04-01 16:26:42 +00:00
name: selftest - env
description:
Just output the environment variables set ( always fails )
category: disabled
stdin:
set
- - -
2012-06-25 16:17:54 +00:00
name: selftest - legacy
description:
Check some things in the LEGACY KSH
category: shell:legacy - yes
stdin:
2012-06-28 20:14:17 +00:00
set + o emacs
set + o vi
[ [ "$(set +o) -o" = * "-o emacs -o" * ] ] && echo 1 = emacs
[ [ "$(set +o) -o" = * "-o vi -o" * ] ] && echo 1 = vi
set - o emacs
set - o vi
[ [ "$(set +o) -o" = * "-o emacs -o" * ] ] && echo 2 = emacs
[ [ "$(set +o) -o" = * "-o vi -o" * ] ] && echo 2 = vi
2012-06-25 16:17:54 +00:00
expected - stdout:
2012-06-28 20:14:17 +00:00
2 = emacs
2 = vi
2012-06-25 16:17:54 +00:00
- - -
2011-02-13 21:13:08 +00:00
name: selftest - direct - builtin - call
description:
Check that direct builtin calls work
stdin:
2012-05-04 21:42:51 +00:00
ln - s "$__progname" cat || cp "$__progname" cat
ln - s "$__progname" echo || cp "$__progname" echo
2011-02-18 22:26:13 +00:00
. /echo -c 'echo foo' | ./c at - u
2011-02-13 21:13:08 +00:00
expected - stdout:
- c echo foo
- - -
2005-05-23 03:06:10 +00:00
name: alias - 1
description:
Check that recursion is detected / avoided in aliases .
stdin:
alias fooBar = fooBar
fooBar
exit 0
expected - stderr - pattern:
/fooBar.*not found.*/
- - -
name: alias - 2
description:
Check that recursion is detected / avoided in aliases .
stdin:
alias fooBar = barFoo
alias barFoo = fooBar
fooBar
barFoo
exit 0
expected - stderr - pattern:
/fooBar.*not found.*\n.*barFoo.*not found/
- - -
name: alias - 3
description:
Check that recursion is detected / avoided in aliases .
stdin:
alias Echo = 'echo '
alias fooBar = barFoo
alias barFoo = fooBar
Echo fooBar
unalias barFoo
Echo fooBar
expected - stdout:
fooBar
barFoo
- - -
name: alias - 4
description:
Check that alias expansion isn ' t done on keywords ( in keyword
postitions ) .
stdin:
alias Echo = 'echo '
alias while = While
while false ; do echo hi ; done
Echo while
expected - stdout:
While
- - -
name: alias - 5
description:
Check that alias expansion done after alias with trailing space .
stdin:
alias Echo = 'echo '
alias foo = 'bar stuff '
alias bar = 'Bar1 Bar2 '
alias stuff = 'Stuff'
alias blah = 'Blah'
Echo foo blah
expected - stdout:
Bar1 Bar2 Stuff Blah
- - -
name: alias - 6
description:
Check that alias expansion done after alias with trailing space .
stdin:
alias Echo = 'echo '
alias foo = 'bar bar'
alias bar = 'Bar '
alias blah = Blah
Echo foo blah
expected - stdout:
Bar Bar Blah
- - -
name: alias - 7
description:
Check that alias expansion done after alias with trailing space
after a keyword .
stdin:
alias X = 'case '
alias Y = Z
X Y in 'Y' ) echo is y ; ; Z ) echo is z ; esac
expected - stdout:
is z
- - -
name: alias - 8
description:
Check that newlines in an alias don ' t cause the command to be lost .
stdin:
alias foo = '
echo hi
echo there
'
foo
expected - stdout:
hi
there
- - -
2008-12-02 12:48:16 +00:00
name: alias - 9
description:
Check that recursion is detected / avoided in aliases .
2008-12-08 13:57:35 +00:00
This check fails for slow machines or Cygwin , raise
the time - limit clause ( e . g . to 7 ) if this occurs .
2008-12-02 13:19:28 +00:00
time - limit: 3
2008-12-02 12:48:16 +00:00
stdin:
2012-12-28 04:25:32 +00:00
print '#!' "$__progname" '\necho tf' > lq
chmod + x lq
2015-07-10 19:36:38 +00:00
PATH = $ PWD $ PATHSEP $ PATH
2012-12-28 04:25:32 +00:00
alias lq = lq
lq
2012-12-28 04:01:17 +00:00
echo = now
2012-12-28 04:25:32 +00:00
i = `lq`
print - r - - $ i
2012-12-28 04:01:17 +00:00
echo = out
2008-12-02 12:48:16 +00:00
exit 0
expected - stdout:
tf
2012-12-28 04:01:17 +00:00
= now
2008-12-02 12:48:16 +00:00
tf
2012-12-28 04:01:17 +00:00
= out
2008-12-02 12:48:16 +00:00
- - -
2010-07-21 11:31:16 +00:00
name: alias - 10
description:
Check that recursion is detected / avoided in aliases .
Regression , introduced during an old bugfix .
stdin:
alias foo = 'print hello '
alias bar = 'foo world'
echo $ ( bar )
expected - stdout:
hello world
- - -
2015-03-14 05:23:18 +00:00
name: alias - 11
description:
Check that special argument handling still applies with escaped aliases
stdin:
alias local = '\typeset'
function foo {
local x = $ 1 y = z
print - r - - "$x,$y"
}
foo 'bar - baz'
expected - stdout:
bar - baz , z
- - -
2015-12-12 22:25:15 +00:00
name: arith - compound
description:
Check that arithmetic expressions are compound constructs
stdin:
{ ! ( ( 0 $ ( cat > & 2 ) ) ) << < 1 ; } << < 2
expected - stderr:
1
- - -
2005-05-23 03:06:10 +00:00
name: arith - lazy - 1
description:
Check that only one side of ternary operator is evaluated
stdin:
x = i += 2
y = j += 2
typeset - i i = 1 j = 1
echo $( ( 1 ? 20 : ( x += 2 ) ) )
echo $ i , $ x
echo $( ( 0 ? ( y += 2 ) : 30 ) )
echo $ j , $ y
expected - stdout:
20
1 , i += 2
30
1 , j += 2
- - -
name: arith - lazy - 2
description:
Check that assignments not done on non - evaluated side of ternary
operator
stdin:
x = i += 2
y = j += 2
typeset - i i = 1 j = 1
echo $( ( 1 ? 20 : ( x += 2 ) ) )
echo $ i , $ x
echo $( ( 0 ? ( y += 2 ) : 30 ) )
echo $ i , $ y
expected - stdout:
20
1 , i += 2
30
1 , j += 2
- - -
2009-10-02 17:05:01 +00:00
name: arith - lazy - 3
description:
Check that assignments not done on non - evaluated side of ternary
operator and this construct is parsed correctly ( Debian #445651)
stdin:
x = 4
y = $( ( 0 ? x = 1 : 2 ) )
echo = $ x $ y =
expected - stdout:
= 4 2 =
- - -
2013-07-21 18:38:56 +00:00
name: arith - lazy - 4
description:
Check that preun / postun not done on non - evaluated side of ternary
operator
stdin:
( ( m = n = 0 , 1 ? n + + : m + + ? 2 : 3 ) )
echo "($n, $m)"
m = 0 ; echo $( ( 0 ? + + m : 2 ) ) ; echo $ m
m = 0 ; echo $( ( 0 ? m + + : 2 ) ) ; echo $ m
expected - stdout:
( 1 , 0 )
2
0
2
0
- - -
2005-05-23 03:06:10 +00:00
name: arith - ternary - prec - 1
description:
2009-10-02 16:59:53 +00:00
Check precedence of ternary operator vs assignment
2005-05-23 03:06:10 +00:00
stdin:
typeset - i x = 2
y = $( ( 1 ? 20 : x += 2 ) )
expected - exit : e != 0
expected - stderr - pattern:
/.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
- - -
name: arith - ternary - prec - 2
description:
2009-10-02 16:59:53 +00:00
Check precedence of ternary operator vs assignment
2005-05-23 03:06:10 +00:00
stdin:
typeset - i x = 2
echo $( ( 0 ? x += 2 : 20 ) )
expected - stdout:
20
- - -
name: arith - div - assoc - 1
description:
Check associativity of division operator
stdin:
echo $( ( 20 / 2 / 2 ) )
expected - stdout:
5
- - -
2011-12-11 01:35:10 +00:00
name: arith - div - byzero
description:
Check division by zero errors out
stdin:
x = $ ( echo $( ( 1 / 0 ) ) )
2011-12-11 01:56:43 +00:00
echo = $? : $ x .
2011-12-11 01:35:10 +00:00
expected - stdout:
2011-12-11 01:56:43 +00:00
= 1 : .
2011-12-11 01:35:10 +00:00
expected - stderr - pattern:
/.*divisor/
- - -
name: arith - div - intmin - by - minusone
description:
2011-12-11 01:56:43 +00:00
Check division overflow wraps around silently
2012-06-28 20:17:39 +00:00
category: int : 32
2011-12-11 01:35:10 +00:00
stdin:
2012-03-26 00:25:52 +00:00
echo signed: $( ( - 2147483648 / - 1 ) ) r $( ( - 2147483648 % - 1 ) ) .
echo unsigned: $( ( # -2147483648 / -1))r$((# -2147483648 % -1)).
2011-12-11 01:35:10 +00:00
expected - stdout:
2012-03-26 00:25:52 +00:00
signed: - 2147483648 r0 .
unsigned:0r2147483648 .
2011-12-11 01:35:10 +00:00
- - -
2012-06-28 20:17:39 +00:00
name: arith - div - intmin - by - minusone - 64
description:
Check division overflow wraps around silently
category: int : 64
stdin:
echo signed: $( ( - 9223372036854775808 / - 1 ) ) r $( ( - 9223372036854775808 % - 1 ) ) .
echo unsigned: $( ( # -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
expected - stdout:
signed: - 9223372036854775808 r0 .
unsigned:0r9223372036854775808 .
- - -
2005-05-23 03:06:10 +00:00
name: arith - assop - assoc - 1
description:
Check associativity of assignment - operator operator
stdin:
typeset - i i = 1 j = 2 k = 3
echo $( ( i += j += k ) )
echo $ i , $ j , $ k
expected - stdout:
6
6 , 5 , 3
- - -
2012-10-03 17:24:23 +00:00
name: arith - mandatory
description:
2013-04-01 01:16:37 +00:00
Passing of this test is * mandatory * for a valid mksh executable !
2012-10-03 17:24:23 +00:00
category: shell:legacy - no
stdin:
typeset - i sari = 0
typeset - Ui uari = 0
typeset - i x = 0
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #0
2012-10-03 17:24:23 +00:00
let - - sari - - uari
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #1
2012-10-03 17:24:23 +00:00
sari = 2147483647 uari = 2147483647
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #2
2012-10-03 17:24:23 +00:00
let + + sari + + uari
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #3
2012-10-03 17:24:23 +00:00
let - - sari - - uari
let 'sari *= 2' 'uari *= 2'
let + + sari + + uari
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #4
2012-10-03 17:24:23 +00:00
let + + sari + + uari
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #5
2012-10-03 17:24:23 +00:00
sari = - 2147483648 uari = - 2147483648
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #6
2012-10-03 17:24:23 +00:00
let - - sari - - uari
2013-04-01 01:16:37 +00:00
print - r - - $( ( x + + ) ) : $ sari = $ uari . #7
( ( sari = - 5 >> 1 ) )
( ( # uari = -5 >> 1 ))
print - r - - $( ( x + + ) ) : $ sari = $ uari . #8
2013-04-01 02:37:53 +00:00
( ( sari = - 2 ) )
( ( # uari = sari ))
print - r - - $( ( x + + ) ) : $ sari = $ uari . #9
2012-10-03 17:24:23 +00:00
expected - stdout:
0 : 0 = 0 .
1 : - 1 = 4294967295 .
2 : 2147483647 = 2147483647 .
3 : - 2147483648 = 2147483648 .
4 : - 1 = 4294967295 .
5 : 0 = 0 .
6 : - 2147483648 = 2147483648 .
7 : 2147483647 = 2147483647 .
2013-04-01 01:16:37 +00:00
8 : - 3 = 2147483645 .
2013-04-01 02:37:53 +00:00
9 : - 2 = 4294967294 .
2012-10-03 17:24:23 +00:00
- - -
2008-12-17 19:39:23 +00:00
name: arith - unsigned - 1
description:
Check if unsigned arithmetics work
2012-06-28 20:17:39 +00:00
category: int : 32
2008-12-17 19:39:23 +00:00
stdin:
# signed vs unsigned
2009-10-02 18:08:37 +00:00
echo x1 $( ( - 1 ) ) $( ( #-1))
2008-12-17 19:39:23 +00:00
# calculating
typeset - i vs
typeset - Ui vu
vs = 4123456789 ; vu = 4123456789
2009-10-02 18:08:37 +00:00
echo x2 $ vs $ vu
2008-12-17 19:39:23 +00:00
( ( vs % = 2147483647 ) )
( ( vu % = 2147483647 ) )
2009-10-02 18:08:37 +00:00
echo x3 $ vs $ vu
2008-12-17 19:39:23 +00:00
vs = 4123456789 ; vu = 4123456789
( ( # vs %= 2147483647 ))
( ( # vu %= 2147483647 ))
2009-10-02 18:08:37 +00:00
echo x4 $ vs $ vu
2008-12-17 19:39:23 +00:00
# make sure the calculation does not change unsigned flag
vs = 4123456789 ; vu = 4123456789
2009-10-02 18:08:37 +00:00
echo x5 $ vs $ vu
2008-12-17 19:39:23 +00:00
# short form
2009-10-02 18:08:37 +00:00
echo x6 $( ( # vs % 2147483647)) $((# vu % 2147483647))
2008-12-17 19:39:23 +00:00
# array refs
set - A va
va [ 1975973142 ] = right
va [ 4123456789 ] = wrong
2009-10-02 18:08:37 +00:00
echo x7 $ { va [ #4123456789%2147483647]}
2015-10-13 21:39:53 +00:00
# make sure multiple calculations don't interfere with each other
let '# mca = -4 % -2' ' mcb = -4 % -2'
echo x8 $ mca $ mcb
2008-12-17 19:39:23 +00:00
expected - stdout:
x1 - 1 4294967295
x2 - 171510507 4123456789
x3 - 171510507 4123456789
x4 1975973142 1975973142
x5 - 171510507 4123456789
x6 1975973142 1975973142
x7 right
2015-10-13 21:39:53 +00:00
x8 - 4 0
2008-12-17 19:39:23 +00:00
- - -
2009-03-14 18:12:55 +00:00
name: arith - limit32 - 1
description:
Check if arithmetics are 32 bit
2012-06-28 20:17:39 +00:00
category: int : 32
2009-03-14 18:12:55 +00:00
stdin:
# signed vs unsigned
2009-10-02 18:08:37 +00:00
echo x1 $( ( - 1 ) ) $( ( #-1))
2009-03-14 18:12:55 +00:00
# calculating
typeset - i vs
typeset - Ui vu
vs = 2147483647 ; vu = 2147483647
2009-10-02 18:08:37 +00:00
echo x2 $ vs $ vu
2009-03-14 18:12:55 +00:00
let vs + + vu + +
2009-10-02 18:08:37 +00:00
echo x3 $ vs $ vu
2009-03-14 18:12:55 +00:00
vs = 4294967295 ; vu = 4294967295
2009-10-02 18:08:37 +00:00
echo x4 $ vs $ vu
2009-03-14 18:12:55 +00:00
let vs + + vu + +
2009-10-02 18:08:37 +00:00
echo x5 $ vs $ vu
2009-03-14 18:12:55 +00:00
let vs + + vu + +
2009-10-02 18:08:37 +00:00
echo x6 $ vs $ vu
2009-03-14 18:12:55 +00:00
expected - stdout:
x1 - 1 4294967295
x2 2147483647 2147483647
x3 - 2147483648 2147483648
x4 - 1 4294967295
x5 0 0
x6 1 1
- - -
2012-06-28 20:17:39 +00:00
name: arith - limit64 - 1
description:
Check if arithmetics are 64 bit
category: int : 64
stdin:
# signed vs unsigned
echo x1 $( ( - 1 ) ) $( ( #-1))
# calculating
typeset - i vs
typeset - Ui vu
vs = 9223372036854775807 ; vu = 9223372036854775807
echo x2 $ vs $ vu
let vs + + vu + +
echo x3 $ vs $ vu
vs = 18446744073709551615 ; vu = 18446744073709551615
echo x4 $ vs $ vu
let vs + + vu + +
echo x5 $ vs $ vu
let vs + + vu + +
echo x6 $ vs $ vu
expected - stdout:
x1 - 1 18446744073709551615
x2 9223372036854775807 9223372036854775807
x3 - 9223372036854775808 9223372036854775808
x4 - 1 18446744073709551615
x5 0 0
x6 1 1
- - -
2005-05-23 03:06:10 +00:00
name: bksl - nl - ign - 1
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is not collapsed after #
2005-05-23 03:06:10 +00:00
stdin:
echo hi #there \
echo folks
expected - stdout:
hi
folks
- - -
name: bksl - nl - ign - 2
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is not collapsed inside single quotes
2005-05-23 03:06:10 +00:00
stdin:
echo ' hi \
there '
echo folks
expected - stdout:
hi \
there
folks
- - -
name: bksl - nl - ign - 3
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is not collapsed inside single quotes
2005-05-23 03:06:10 +00:00
stdin:
cat << \ EOF
hi \
there
EOF
expected - stdout:
hi \
there
- - -
2007-09-07 23:57:14 +00:00
name: bksl - nl - ign - 4
2005-05-23 03:06:10 +00:00
description:
Check interaction of aliases , single quotes and here - documents
with backslash - newline
2009-10-02 18:08:37 +00:00
( don ' t know what POSIX has to say about this )
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
a = 2
alias x = ' echo hi
cat << "EOF"
foo \
bar
some '
x
more \
stuff $ a
EOF
expected - stdout:
hi
foo \
bar
some
more \
stuff $ a
- - -
2007-09-07 23:57:14 +00:00
name: bksl - nl - ign - 5
2005-05-23 03:06:10 +00:00
description:
Check what happens with backslash at end of input
2009-10-02 18:08:37 +00:00
( the old Bourne shell trashes them ; so do we )
2005-05-23 03:06:10 +00:00
stdin: !
echo `echo foo\\` bar
echo hi \
expected - stdout:
foobar
hi
- - -
#
# Places \newline should be collapsed
#
name: bksl - nl - 1
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed before , in the middle of , and
2005-05-23 03:06:10 +00:00
after words
stdin:
\
echo hi \
There , \
folks
expected - stdout:
hiThere , folks
- - -
name: bksl - nl - 2
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in $ sequences
2005-05-23 03:06:10 +00:00
( ksh93 fails this )
stdin:
a = 12
ab = 19
echo $\
a
echo $ a \
b
echo $\
{ a }
echo $ { a \
b }
echo $ { ab \
}
expected - stdout:
12
19
12
19
19
- - -
name: bksl - nl - 3
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in $( .. ) and `...` sequences
2005-05-23 03:06:10 +00:00
( ksh93 fails this )
stdin:
echo $\
( echo foobar1 )
echo $( \
echo foobar2 )
echo $ ( echo foo \
bar3 )
echo $ ( echo foobar4 \
)
echo `
echo stuff1 `
echo ` echo st \
uff2 `
expected - stdout:
foobar1
foobar2
foobar3
foobar4
stuff1
stuff2
- - -
name: bksl - nl - 4
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in $( ( .. ) ) sequences
2005-05-23 03:06:10 +00:00
( ksh93 fails this )
stdin:
echo $\
( ( 1 + 2 ) )
echo $( \
( 1 + 2 + 3 ) )
echo $( ( \
1 + 2 + 3 + 4 ) )
echo $( ( 1 + \
2 + 3 + 4 + 5 ) )
echo $( ( 1 + 2 + 3 + 4 + 5 + 6 ) \
)
expected - stdout:
3
6
10
15
21
- - -
name: bksl - nl - 5
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in double quoted strings
2005-05-23 03:06:10 +00:00
stdin:
echo " \
hi "
echo " foo \
bar "
echo " folks \
"
expected - stdout:
hi
foobar
folks
- - -
name: bksl - nl - 6
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in here document delimiters
2005-05-23 03:06:10 +00:00
( ksh93 fails second part of this )
stdin:
a = 12
cat << EO \
F
a = $ a
foo \
bar
EOF
cat << E_O_F
foo
E_O_ \
F
echo done
expected - stdout:
a = 12
foobar
foo
done
- - -
name: bksl - nl - 7
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in double - quoted here - document
2005-05-23 03:06:10 +00:00
delimiter .
stdin:
a = 12
cat << " EO \
F "
a = $ a
foo \
bar
EOF
echo done
expected - stdout:
a = $ a
foo \
bar
done
- - -
name: bksl - nl - 8
description:
2011-01-30 02:18:25 +00:00
Check that \ newline is collapsed in various 2 + character tokens
2005-05-23 03:06:10 +00:00
delimiter .
( ksh93 fails this )
stdin:
echo hi & \
& echo there
echo foo | \
| echo bar
cat < \
< EOF
stuff
EOF
cat < \
< \
- EOF
more stuff
EOF
cat << \
EOF
abcdef
EOF
echo hi > \
> /dev/ null
echo $?
i = 1
case $ i in
( \
x | \
1 \
) echo hi ; \
;
( * ) echo oops
esac
expected - stdout:
hi
there
foo
stuff
more stuff
abcdef
0
hi
- - -
2007-09-07 23:57:14 +00:00
name: bksl - nl - 9
2005-05-23 03:06:10 +00:00
description:
Check that \ at the end of an alias is collapsed when followed
by a newline
2009-10-02 18:08:37 +00:00
( don ' t know what POSIX has to say about this )
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
alias x = ' echo hi \ '
x
echo there
expected - stdout:
hiecho there
- - -
2007-09-07 23:57:14 +00:00
name: bksl - nl - 10
2005-05-23 03:06:10 +00:00
description:
Check that \ newline in a keyword is collapsed
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
i \
f true ; then \
echo pass ; el \
se echo fail ; fi
expected - stdout:
pass
- - -
#
# Places \newline should be collapsed (ksh extensions)
#
2007-09-07 23:57:14 +00:00
name: bksl - nl - ksh - 1
2005-05-23 03:06:10 +00:00
description:
Check that \ newline is collapsed in extended globbing
( ksh93 fails this )
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
xxx = foo
case $ xxx in
( f * \
( \
o \
) \
) echo ok ; ;
* ) echo bad
esac
expected - stdout:
ok
- - -
2007-09-07 23:57:14 +00:00
name: bksl - nl - ksh - 2
2005-05-23 03:06:10 +00:00
description:
Check that \ newline is collapsed in ( ( ... ) ) expressions
( ksh93 fails this )
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
i = 1
( \
( \
i = i + 2 \
) \
)
echo $ i
expected - stdout:
3
- - -
name: break - 1
description:
See if break breaks out of loops
stdin:
for i in a b c ; do echo $ i ; break ; echo bad - $ i ; done
echo end - 1
for i in a b c ; do echo $ i ; break 1 ; echo bad - $ i ; done
echo end - 2
for i in a b c ; do
for j in x y z ; do
echo $ i: $ j
break
echo bad - $ i
done
echo end - $ i
done
echo end - 3
expected - stdout:
a
end - 1
a
end - 2
a:x
end - a
b:x
end - b
c:x
end - c
end - 3
- - -
name: break - 2
description:
See if break breaks out of nested loops
stdin:
for i in a b c ; do
for j in x y z ; do
echo $ i: $ j
break 2
echo bad - $ i
done
echo end - $ i
done
echo end
expected - stdout:
a:x
end
- - -
name: break - 3
description:
What if break used outside of any loops
( ksh88 , ksh93 don ' t print error messages here )
stdin:
break
expected - stderr - pattern:
/.*break.*/
- - -
name: break - 4
description:
What if break N used when only N - 1 loops
( ksh88 , ksh93 don ' t print error messages here )
stdin:
for i in a b c ; do echo $ i ; break 2 ; echo bad - $ i ; done
echo end
expected - stdout:
a
end
expected - stderr - pattern:
/.*break.*/
- - -
name: break - 5
description:
Error if break argument isn ' t a number
stdin:
for i in a b c ; do echo $ i ; break abc ; echo more - $ i ; done
echo end
expected - stdout:
a
expected - exit : e != 0
expected - stderr - pattern:
/.*break.*/
- - -
name: continue - 1
description:
See if continue continues loops
stdin:
for i in a b c ; do echo $ i ; continue ; echo bad - $ i ; done
echo end - 1
for i in a b c ; do echo $ i ; continue 1 ; echo bad - $ i ; done
echo end - 2
for i in a b c ; do
for j in x y z ; do
echo $ i: $ j
continue
echo bad - $ i - $ j
done
echo end - $ i
done
echo end - 3
expected - stdout:
a
b
c
end - 1
a
b
c
end - 2
a:x
a:y
a:z
end - a
b:x
b:y
b:z
end - b
c:x
c:y
c:z
end - c
end - 3
- - -
name: continue - 2
description:
See if continue breaks out of nested loops
stdin:
for i in a b c ; do
for j in x y z ; do
echo $ i: $ j
continue 2
echo bad - $ i - $ j
done
echo end - $ i
done
echo end
expected - stdout:
a:x
b:x
c:x
end
- - -
name: continue - 3
description:
What if continue used outside of any loops
( ksh88 , ksh93 don ' t print error messages here )
stdin:
continue
expected - stderr - pattern:
/.*continue.*/
- - -
name: continue - 4
description:
What if continue N used when only N - 1 loops
( ksh88 , ksh93 don ' t print error messages here )
stdin:
for i in a b c ; do echo $ i ; continue 2 ; echo bad - $ i ; done
echo end
expected - stdout:
a
b
c
end
expected - stderr - pattern:
/.*continue.*/
- - -
name: continue - 5
description:
Error if continue argument isn ' t a number
stdin:
for i in a b c ; do echo $ i ; continue abc ; echo more - $ i ; done
echo end
expected - stdout:
a
expected - exit : e != 0
expected - stderr - pattern:
/.*continue.*/
- - -
name: cd - history
description:
Test someone ' s CD history package ( uses arrays )
stdin:
# go to known place before doing anything
cd /
alias cd = _cd
function _cd
{
typeset - i cdlen i
typeset t
if [ $# - eq 0 ]
then
set - - $ HOME
fi
if [ "$CDHISTFILE" - a - r "$CDHISTFILE" ] # if directory history exists
then
typeset CDHIST
i = - 1
while read - r t # read directory history file
do
CDHIST [ i = i + 1 ] = $ t
done < $ CDHISTFILE
fi
if [ "${CDHIST[0]}" != "$PWD" - a "$PWD" != "" ]
then
_cdins # insert $PWD into cd history
fi
cdlen = $ { #CDHIST[*]} # number of elements in history
case "$@" in
- ) # cd to new dir
if [ "$OLDPWD" = "" ] && ( ( cdlen > 1 ) )
then
'print' $ { CDHIST [ 1 ] }
'cd' $ { CDHIST [ 1 ] }
_pwd
else
'cd' $@
_pwd
fi
; ;
- l ) # print directory list
typeset - R3 num
( ( i = cdlen ) )
while ( ( ( i = i - 1 ) >= 0 ) )
do
num = $ i
'print' "$num ${CDHIST[i]}"
done
return
; ;
- [ 0 - 9 ] | - [ 0 - 9 ] [ 0 - 9 ] ) # cd to dir in list
if ( ( ( i = $ { 1 #-})<cdlen))
then
'print' $ { CDHIST [ i ] }
'cd' $ { CDHIST [ i ] }
_pwd
else
'cd' $@
_pwd
fi
; ;
- * ) # cd to matched dir in list
t = $ { 1 #-}
i = 1
while ( ( i < cdlen ) )
do
case $ { CDHIST [ i ] } in
* $ t * )
'print' $ { CDHIST [ i ] }
'cd' $ { CDHIST [ i ] }
_pwd
break
; ;
esac
( ( i = i + 1 ) )
done
if ( ( i >= cdlen ) )
then
'cd' $@
_pwd
fi
; ;
* ) # cd to new dir
'cd' $@
_pwd
; ;
esac
_cdins # insert $PWD into cd history
if [ "$CDHISTFILE" ]
then
cdlen = $ { #CDHIST[*]} # number of elements in history
i = 0
while ( ( i < cdlen ) )
do
'print' - r $ { CDHIST [ i ] } # update directory history
( ( i = i + 1 ) )
done > $ CDHISTFILE
fi
}
function _cdins # insert $PWD into cd history
{ # meant to be called only by _cd
typeset - i i
( ( i = 0 ) )
while ( ( i < $ { #CDHIST[*]})) # see if dir is already in list
do
if [ "${CDHIST[$i]}" = "$PWD" ]
then
break
fi
( ( i = i + 1 ) )
done
if ( ( i > 22 ) ) # limit max size of list
then
i = 22
fi
while ( ( ( i = i - 1 ) >= 0 ) ) # bump old dirs in list
do
CDHIST [ i + 1 ] = $ { CDHIST [ i ] }
done
CDHIST [ 0 ] = $ PWD # insert new directory in list
}
function _pwd
{
if [ - n "$ECD" ]
then
pwd 1 > & 6
fi
}
# Start of test
cd / tmp
cd / bin
cd / etc
cd -
cd - 2
cd - l
expected - stdout:
/ bin
/ tmp
3 /
2 / etc
1 / bin
0 / tmp
- - -
2011-05-29 02:18:57 +00:00
name: cd - pe
description:
Check package for cd - Pe
need - pass: no
2011-05-29 16:31:42 +00:00
# the mv command fails on Cygwin
2011-11-19 17:25:55 +00:00
# Hurd aborts the testsuite (permission denied)
2012-12-28 07:45:55 +00:00
# QNX does not find subdir to cd into
2015-04-29 20:13:47 +00:00
category: ! os:cygwin , ! os:gnu , ! os:msys , ! os:nto , ! os:os390 , ! nosymlink
2011-05-29 02:18:57 +00:00
file - setup: file 644 "x"
mkdir noread noread /target noread/ target / subdir
ln - s noread link
chmod 311 noread
cd - P $ 1 .
echo 0 = $?
bwd = $ PWD
cd - P $ 1 link / target
echo 1 = $? , $ { PWD #$bwd/}
epwd = $( $ TSHELL - c pwd 2 > /dev/ null )
2011-05-29 16:31:42 +00:00
# This unexpectedly succeeds on GNU/Linux and MidnightBSD
#echo pwd=$?,$epwd
# expect: pwd=1,
2011-05-29 02:18:57 +00:00
mv .. /../ noread .. /../ renamed
cd - P $ 1 subdir
echo 2 = $? , $ { PWD #$bwd/}
cd $ bwd
chmod 755 renamed
rm - rf noread link renamed
stdin:
export TSHELL = "$__progname"
"$__progname" x
echo "now with -e:"
"$__progname" x e
expected - stdout:
0 = 0
1 = 0 , noread / target
2 = 0 , noread /target/s ubdir
now with - e:
0 = 0
1 = 0 , noread / target
2 = 1 , noread /target/s ubdir
- - -
2005-05-23 03:06:10 +00:00
name: env - prompt
description:
Check that prompt not printed when processing ENV
env - setup: ! ENV = . / foo !
file - setup: file 644 "foo"
XXX = _
PS1 = X
false && echo hmmm
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
echo hi $ { XXX } there
expected - stdout:
hi_there
expected - stderr: !
XX
- - -
2010-02-23 21:51:49 +00:00
name: expand - ugly
2010-02-18 17:31:23 +00:00
description:
2010-02-25 20:18:19 +00:00
Check that weird $ { foo + bar } constructs are parsed correctly
2010-02-18 17:31:23 +00:00
stdin:
2012-03-31 18:26:53 +00:00
print '#!' "$__progname" '\nfor x in "$@"; do print -r -- "$x"; done' > pfn
print '#!' "$__progname" '\nfor x in "$@"; do print -nr -- "<$x> "; done' > pfs
chmod + x pfn pfs
2013-02-10 19:04:00 +00:00
( echo 1 $ { IFS + '}' z } ) 2 > /dev/ null || echo failed in 1
( echo 2 "${IFS+'}'z}" ) 2 > /dev/ null || echo failed in 2
( echo 3 "foo ${IFS+'bar} baz" ) 2 > /dev/ null || echo failed in 3
( echo - n '4 ' ; . /pfn "foo ${IFS+"b c"} baz") 2>/ dev / null || echo failed in 4
( echo - n '5 ' ; . /pfn "foo ${IFS+b c} baz") 2>/ dev / null || echo failed in 5
( echo 6 $ { IFS + "}" z } ) 2 > /dev/ null || echo failed in 6
( echo 7 "${IFS+" } "z}" ) 2 > /dev/ null || echo failed in 7
( echo 8 "${IFS+\"}\"z}" ) 2 > /dev/ null || echo failed in 8
( echo 9 "${IFS+\"\}\"z}" ) 2 > /dev/ null || echo failed in 9
( echo 10 foo $ { IFS + 'bar} baz' } ) 2 > /dev/ null || echo failed in 10
( echo 11 "$(echo " $ { IFS + '}' z } ")" ) 2 > /dev/ null || echo failed in 11
( echo 12 "$(echo ${IFS+'}'z})" ) 2 > /dev/ null || echo failed in 12
( echo 13 $ { IFS + \ } z } ) 2 > /dev/ null || echo failed in 13
( echo 14 "${IFS+\}z}" ) 2 > /dev/ null || echo failed in 14
u = x ; ( echo - n '15 ' ; . /pfs "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>/ dev / null || echo failed in 15
l = t ; ( echo 16 $ { IFS + h `echo -n i ${IFS+$l}h` ere } ) 2 > /dev/ null || echo failed in 16
l = t ; ( echo 17 $ { IFS + h $ ( echo - n i $ { IFS + $ l } h ) ere } ) 2 > /dev/ null || echo failed in 17
l = t ; ( echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}" ) 2 > /dev/ null || echo failed in 18
l = t ; ( echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}" ) 2 > /dev/ null || echo failed in 19
l = t ; ( echo 20 $ { IFS + h `echo -n i "${IFS+$l}"h` ere } ) 2 > /dev/ null || echo failed in 20
l = t ; ( echo 21 $ { IFS + h $ ( echo - n i "${IFS+$l}" h ) ere } ) 2 > /dev/ null || echo failed in 21
l = t ; ( echo 22 "${IFS+h`echo -n i " $ { IFS + $ l } "h`ere}" ) 2 > /dev/ null || echo failed in 22
l = t ; ( echo 23 "${IFS+h$(echo -n i " $ { IFS + $ l } "h)ere}" ) 2 > /dev/ null || echo failed in 23
key = value ; ( echo - n '24 ' ; . /pfn "${IFS+'$key'}") 2>/ dev / null || echo failed in 24
key = value ; ( echo - n '25 ' ; . /pfn "${IFS+"'$key'"}") 2>/ dev / null || echo failed in 25 # ksh93: “'$key'”
key = value ; ( echo - n '26 ' ; . /pfn ${IFS+'$key'}) 2>/ dev / null || echo failed in 26
key = value ; ( echo - n '27 ' ; . /pfn ${IFS+"'$key'"}) 2>/ dev / null || echo failed in 27
( echo - n '28 ' ; . /pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/ dev / null || echo failed in 28
u = x ; ( echo - n '29 ' ; . /pfs foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>/ dev / null || echo failed in 29
2012-03-31 18:26:53 +00:00
( echo - n '30 ' ; . / pfs $ { IFS + foo ' b \
2013-02-10 19:04:00 +00:00
ar ' baz } ; echo . ) 2 > /dev/ null || ( echo failed in 30 ; echo failed in 31 )
2012-03-31 18:26:53 +00:00
( echo - n '32 ' ; . / pfs $ { IFS + foo " b \
2013-02-10 19:04:00 +00:00
ar " baz } ; echo . ) 2 > /dev/ null || echo failed in 32
2012-03-31 18:26:53 +00:00
( echo - n '33 ' ; . / pfs " $ { IFS + foo ' b \
2013-02-10 19:04:00 +00:00
ar ' baz } " ; echo . ) 2 > /dev/ null || echo failed in 33
2012-03-31 18:26:53 +00:00
( echo - n '34 ' ; . / pfs "${IFS+foo " b \
2013-02-10 19:04:00 +00:00
ar " baz}" ; echo . ) 2 > /dev/ null || echo failed in 34
( echo - n '35 ' ; . /pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/ dev / null || echo failed in 35
( echo - n '36 ' ; . /pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/ dev / null || echo failed in 36
( echo - n '37 ' ; . /pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/ dev / null || echo failed in 37
( echo 38 $ { IFS + x 'a' y } / "${IFS+x'a'y}" .) 2>/ dev / null || echo failed in 38
foo = "x'a'y" ; ( echo 39 $ { foo % * ' a '*} / "${foo%*' a ' * } " . ) 2 > /dev/ null || echo failed in 39
foo = "a b c" ; ( echo - n '40 ' ; . /pfs "${foo#a}"; echo .) 2>/ dev / null || echo failed in 40
2010-02-23 21:51:49 +00:00
expected - stdout:
1 } z
2 '' z }
3 foo ' bar baz
2010-02-25 11:47:33 +00:00
4 foo b c baz
5 foo b c baz
6 } z
2010-02-23 21:51:49 +00:00
7 } z
2010-02-25 11:47:33 +00:00
8 "" z }
9 "}" z
10 foo bar } baz
11 '' z }
12 } z
2010-02-23 21:51:49 +00:00
13 } z
14 } z
2010-02-25 20:18:19 +00:00
15 < foo abx { { { { } b c d { } bar > <}> <baz> .
2010-02-25 11:47:33 +00:00
16 hi there
2010-02-23 21:51:49 +00:00
17 hi there
18 hi there
19 hi there
20 hi there
21 hi there
22 hi there
23 hi there
2010-02-25 11:47:33 +00:00
24 'value'
25 'value'
26 $ key
2010-02-25 20:18:19 +00:00
27 'value'
28 'x ~ x' ' x } "x}" #
29 <foo> < abx { { { > <{}b> <c> <d{}> <bar> <}> <baz> .
30 <foo> < b \
ar > <baz> .
32 <foo> <bar> <baz> .
2010-03-18 19:45:39 +00:00
33 < foo 'bar' baz > .
34 < foo bar baz > .
35 <a> <b> <x> <a> <b> .
36 < a \ b > <x> < a \ b > .
37 < a b > <x> < c d > .
2010-04-08 13:21:08 +00:00
38 xay / x 'a' y .
39 x ' / x' .
2010-04-20 09:10:07 +00:00
40 < b c > .
2010-02-23 21:51:49 +00:00
- - -
name: expand - unglob - dblq
description:
2010-02-25 20:18:19 +00:00
Check that regular "${foo+bar}" constructs are parsed correctly
2010-02-23 21:51:49 +00:00
stdin:
u = x
2010-02-18 17:31:23 +00:00
tl_norm ( ) {
v = $ 2
2010-02-23 21:51:49 +00:00
test x "$v" = x "-" && unset v
2010-02-18 17:31:23 +00:00
( echo "$1 plus norm foo ${v+'bar'} baz" )
( echo "$1 dash norm foo ${v-'bar'} baz" )
( echo "$1 eqal norm foo ${v='bar'} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 qstn norm foo ${v?'bar'} baz" ) 2 > /dev/ null || \
2010-02-18 17:31:23 +00:00
echo "$1 qstn norm -> error"
( echo "$1 PLUS norm foo ${v:+'bar'} baz" )
( echo "$1 DASH norm foo ${v:-'bar'} baz" )
( echo "$1 EQAL norm foo ${v:='bar'} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 QSTN norm foo ${v:?'bar'} baz" ) 2 > /dev/ null || \
2010-02-18 17:31:23 +00:00
echo "$1 QSTN norm -> error"
}
tl_paren ( ) {
v = $ 2
2010-02-23 21:51:49 +00:00
test x "$v" = x "-" && unset v
2010-02-18 17:31:23 +00:00
( echo "$1 plus parn foo ${v+(bar)} baz" )
( echo "$1 dash parn foo ${v-(bar)} baz" )
( echo "$1 eqal parn foo ${v=(bar)} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 qstn parn foo ${v?(bar)} baz" ) 2 > /dev/ null || \
2010-02-18 17:31:23 +00:00
echo "$1 qstn parn -> error"
( echo "$1 PLUS parn foo ${v:+(bar)} baz" )
( echo "$1 DASH parn foo ${v:-(bar)} baz" )
( echo "$1 EQAL parn foo ${v:=(bar)} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 QSTN parn foo ${v:?(bar)} baz" ) 2 > /dev/ null || \
2010-02-18 17:31:23 +00:00
echo "$1 QSTN parn -> error"
}
2010-02-23 21:51:49 +00:00
tl_brace ( ) {
v = $ 2
test x "$v" = x "-" && unset v
( echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz" )
( echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz" )
( echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz" ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 qstn brac -> error"
( echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz" )
( echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz" )
( echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz" )
2013-02-10 19:04:00 +00:00
( echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz" ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 QSTN brac -> error"
}
tl_norm 1 -
2010-02-18 17:31:23 +00:00
tl_norm 2 ''
tl_norm 3 x
2010-02-23 21:51:49 +00:00
tl_paren 4 -
2010-02-18 17:31:23 +00:00
tl_paren 5 ''
tl_paren 6 x
2010-02-23 21:51:49 +00:00
tl_brace 7 -
tl_brace 8 ''
tl_brace 9 x
2010-02-18 17:31:23 +00:00
expected - stdout:
2010-02-23 21:51:49 +00:00
1 plus norm foo baz
1 dash norm foo 'bar' baz
1 eqal norm foo 'bar' baz
1 qstn norm - > error
2010-02-18 17:31:23 +00:00
1 PLUS norm foo baz
2010-02-23 21:51:49 +00:00
1 DASH norm foo 'bar' baz
1 EQAL norm foo 'bar' baz
2010-02-18 17:31:23 +00:00
1 QSTN norm - > error
2010-02-23 21:51:49 +00:00
2 plus norm foo 'bar' baz
2010-02-18 17:31:23 +00:00
2 dash norm foo baz
2 eqal norm foo baz
2 qstn norm foo baz
2 PLUS norm foo baz
2010-02-23 21:51:49 +00:00
2 DASH norm foo 'bar' baz
2 EQAL norm foo 'bar' baz
2010-02-18 17:31:23 +00:00
2 QSTN norm - > error
2010-02-23 21:51:49 +00:00
3 plus norm foo 'bar' baz
2010-02-18 17:31:23 +00:00
3 dash norm foo x baz
3 eqal norm foo x baz
3 qstn norm foo x baz
2010-02-23 21:51:49 +00:00
3 PLUS norm foo 'bar' baz
2010-02-18 17:31:23 +00:00
3 DASH norm foo x baz
3 EQAL norm foo x baz
3 QSTN norm foo x baz
2010-02-23 21:51:49 +00:00
4 plus parn foo baz
4 dash parn foo ( bar ) baz
4 eqal parn foo ( bar ) baz
4 qstn parn - > error
2010-02-18 17:31:23 +00:00
4 PLUS parn foo baz
4 DASH parn foo ( bar ) baz
4 EQAL parn foo ( bar ) baz
4 QSTN parn - > error
5 plus parn foo ( bar ) baz
5 dash parn foo baz
5 eqal parn foo baz
5 qstn parn foo baz
5 PLUS parn foo baz
5 DASH parn foo ( bar ) baz
5 EQAL parn foo ( bar ) baz
5 QSTN parn - > error
6 plus parn foo ( bar ) baz
6 dash parn foo x baz
6 eqal parn foo x baz
6 qstn parn foo x baz
6 PLUS parn foo ( bar ) baz
6 DASH parn foo x baz
6 EQAL parn foo x baz
6 QSTN parn foo x baz
2010-02-23 21:51:49 +00:00
7 plus brac foo c } baz
7 dash brac foo ax { { { } b c d { } baz
7 eqal brac foo ax { { { } b c ax { { { } b } baz
7 qstn brac - > error
7 PLUS brac foo c } baz
7 DASH brac foo ax { { { } b c d { } baz
7 EQAL brac foo ax { { { } b c ax { { { } b } baz
7 QSTN brac - > error
8 plus brac foo ax { { { } b c d { } baz
8 dash brac foo c } baz
8 eqal brac foo c } baz
8 qstn brac foo c } baz
8 PLUS brac foo c } baz
8 DASH brac foo ax { { { } b c d { } baz
8 EQAL brac foo ax { { { } b c ax { { { } b } baz
8 QSTN brac - > error
9 plus brac foo ax { { { } b c d { } baz
9 dash brac foo x c x } baz
9 eqal brac foo x c x } baz
9 qstn brac foo x c x } baz
9 PLUS brac foo ax { { { } b c d { } baz
9 DASH brac foo x c x } baz
9 EQAL brac foo x c x } baz
9 QSTN brac foo x c x } baz
- - -
name: expand - unglob - unq
description:
2010-02-25 20:18:19 +00:00
Check that regular $ { foo + bar } constructs are parsed correctly
2010-02-23 21:51:49 +00:00
stdin:
u = x
tl_norm ( ) {
v = $ 2
test x "$v" = x "-" && unset v
( echo $ 1 plus norm foo $ { v + 'bar' } baz )
( echo $ 1 dash norm foo $ { v - 'bar' } baz )
( echo $ 1 eqal norm foo $ { v = 'bar' } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 qstn norm foo $ { v ? 'bar' } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 qstn norm -> error"
( echo $ 1 PLUS norm foo $ { v: + 'bar' } baz )
( echo $ 1 DASH norm foo $ { v: - 'bar' } baz )
( echo $ 1 EQAL norm foo $ { v: = 'bar' } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 QSTN norm foo $ { v: ? 'bar' } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 QSTN norm -> error"
}
tl_paren ( ) {
v = $ 2
test x "$v" = x "-" && unset v
( echo $ 1 plus parn foo $ { v + \ ( bar ')' } baz )
( echo $ 1 dash parn foo $ { v - \ ( bar ')' } baz )
( echo $ 1 eqal parn foo $ { v = \ ( bar ')' } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 qstn parn foo $ { v ? \ ( bar ')' } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 qstn parn -> error"
( echo $ 1 PLUS parn foo $ { v: + \ ( bar ')' } baz )
( echo $ 1 DASH parn foo $ { v: - \ ( bar ')' } baz )
( echo $ 1 EQAL parn foo $ { v: = \ ( bar ')' } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 QSTN parn foo $ { v: ? \ ( bar ')' } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 QSTN parn -> error"
}
tl_brace ( ) {
v = $ 2
test x "$v" = x "-" && unset v
( echo $ 1 plus brac foo $ { v + a $ u { { { \ } b } c $ { v + d { } } baz )
( echo $ 1 dash brac foo $ { v - a $ u { { { \ } b } c $ { v - d { } } baz )
( echo $ 1 eqal brac foo $ { v = a $ u { { { \ } b } c $ { v = d { } } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 qstn brac foo $ { v ? a $ u { { { \ } b } c $ { v ? d { } } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 qstn brac -> error"
( echo $ 1 PLUS brac foo $ { v: + a $ u { { { \ } b } c $ { v: + d { } } baz )
( echo $ 1 DASH brac foo $ { v: - a $ u { { { \ } b } c $ { v: - d { } } baz )
( echo $ 1 EQAL brac foo $ { v: = a $ u { { { \ } b } c $ { v: = d { } } baz )
2013-02-10 19:04:00 +00:00
( echo $ 1 QSTN brac foo $ { v: ? a $ u { { { \ } b } c $ { v: ? d { } } baz ) 2 > /dev/ null || \
2010-02-23 21:51:49 +00:00
echo "$1 QSTN brac -> error"
}
tl_norm 1 -
tl_norm 2 ''
tl_norm 3 x
tl_paren 4 -
tl_paren 5 ''
tl_paren 6 x
tl_brace 7 -
tl_brace 8 ''
tl_brace 9 x
expected - stdout:
1 plus norm foo baz
1 dash norm foo bar baz
1 eqal norm foo bar baz
1 qstn norm - > error
1 PLUS norm foo baz
1 DASH norm foo bar baz
1 EQAL norm foo bar baz
1 QSTN norm - > error
2 plus norm foo bar baz
2 dash norm foo baz
2 eqal norm foo baz
2 qstn norm foo baz
2 PLUS norm foo baz
2 DASH norm foo bar baz
2 EQAL norm foo bar baz
2 QSTN norm - > error
3 plus norm foo bar baz
3 dash norm foo x baz
3 eqal norm foo x baz
3 qstn norm foo x baz
3 PLUS norm foo bar baz
3 DASH norm foo x baz
3 EQAL norm foo x baz
3 QSTN norm foo x baz
4 plus parn foo baz
4 dash parn foo ( bar ) baz
4 eqal parn foo ( bar ) baz
4 qstn parn - > error
4 PLUS parn foo baz
4 DASH parn foo ( bar ) baz
4 EQAL parn foo ( bar ) baz
4 QSTN parn - > error
5 plus parn foo ( bar ) baz
5 dash parn foo baz
5 eqal parn foo baz
5 qstn parn foo baz
5 PLUS parn foo baz
5 DASH parn foo ( bar ) baz
5 EQAL parn foo ( bar ) baz
5 QSTN parn - > error
6 plus parn foo ( bar ) baz
6 dash parn foo x baz
6 eqal parn foo x baz
6 qstn parn foo x baz
6 PLUS parn foo ( bar ) baz
6 DASH parn foo x baz
6 EQAL parn foo x baz
6 QSTN parn foo x baz
7 plus brac foo c } baz
7 dash brac foo ax { { { } b c d { } baz
7 eqal brac foo ax { { { } b c ax { { { } b } baz
7 qstn brac - > error
7 PLUS brac foo c } baz
7 DASH brac foo ax { { { } b c d { } baz
7 EQAL brac foo ax { { { } b c ax { { { } b } baz
7 QSTN brac - > error
8 plus brac foo ax { { { } b c d { } baz
8 dash brac foo c } baz
8 eqal brac foo c } baz
8 qstn brac foo c } baz
8 PLUS brac foo c } baz
8 DASH brac foo ax { { { } b c d { } baz
8 EQAL brac foo ax { { { } b c ax { { { } b } baz
8 QSTN brac - > error
9 plus brac foo ax { { { } b c d { } baz
9 dash brac foo x c x } baz
9 eqal brac foo x c x } baz
9 qstn brac foo x c x } baz
9 PLUS brac foo ax { { { } b c d { } baz
9 DASH brac foo x c x } baz
9 EQAL brac foo x c x } baz
9 QSTN brac foo x c x } baz
2010-02-18 17:31:23 +00:00
- - -
2011-03-12 01:04:39 +00:00
name: expand - threecolons - dblq
description:
Check for a particular thing that used to segfault
stdin:
TEST = 1234
echo "${TEST:1:2:3}"
echo $? but still living
expected - stderr - pattern:
2011-03-12 23:06:43 +00:00
/bad substitution/
expected - exit : 1
2011-03-12 01:04:39 +00:00
- - -
name: expand - threecolons - unq
description:
Check for a particular thing that used to not error out
stdin:
TEST = 1234
echo $ { TEST:1:2:3 }
echo $? but still living
expected - stderr - pattern:
2011-03-12 23:06:43 +00:00
/bad substitution/
expected - exit : 1
2011-03-12 01:04:39 +00:00
- - -
2011-03-26 16:19:29 +00:00
name: expand - weird - 1
2011-03-26 16:11:43 +00:00
description:
Check corner case of trim expansion vs . $# vs . $ { #var}
stdin:
set 1 2 3 4 5 6 7 8 9 10 11
echo $ { #} # value of $#
echo $ { ##} # length of $#
echo $ { ##1} # $# trimmed 1
set 1 2 3 4 5 6 7 8 9 10 11 12
echo $ { ##1}
expected - stdout:
11
2
1
2
- - -
2011-03-26 16:19:29 +00:00
name: expand - weird - 2
description:
Check corner case of $ { var ? } vs . $ { #var}
stdin:
( exit 0 )
echo $? = $ { #?} .
( exit 111 )
echo $? = $ { #?} .
expected - stdout:
0 = 1 .
111 = 3 .
- - -
2012-06-28 20:03:20 +00:00
name: expand - weird - 3
description:
Check that trimming works with positional parameters ( Debian #48453)
stdin:
A = 9999 - 02
B = 9999
echo 1 = $ { A #$B?}.
set - - $ A $ B
echo 2 = $ { 1 #$2?}.
expected - stdout:
1 = 02 .
2 = 02 .
- - -
2015-12-12 22:25:15 +00:00
name: expand - weird - 4
description:
Check that tilde expansion is enabled in $ { x #~}
and cases that are modelled after it ( $ { x /~/ ~ } )
stdin:
HOME = / etc
a = "~/x"
echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
expected - stdout:
<~/x> </x> <~> <\~> <~> <~> <~/x> <~//etc> <~/~>
- - -
2014-01-05 21:57:29 +00:00
name: expand - number - 1
description:
Check that positional arguments do not overflow
stdin:
echo "1 ${12345678901234567890} ."
expected - stdout:
1 .
- - -
2005-05-23 03:06:10 +00:00
name: eglob - bad - 1
description:
Check that globbing isn ' t done when glob has syntax error
file - setup: file 644 "abcx"
file - setup: file 644 "abcz"
file - setup: file 644 "bbc"
stdin:
echo ! ( [ * ) *
echo + ( a | b [ ) *
expected - stdout:
! ( [ * ) *
+ ( a | b [ ) *
- - -
name: eglob - bad - 2
description:
Check that globbing isn ' t done when glob has syntax error
2009-06-11 12:42:21 +00:00
( AT & T ksh fails this test )
2005-05-23 03:06:10 +00:00
file - setup: file 644 "abcx"
file - setup: file 644 "abcz"
file - setup: file 644 "bbc"
stdin:
echo [ a * ( ] * ) z
expected - stdout:
[ a * ( ] * ) z
- - -
name: eglob - infinite - plus
description:
Check that shell doesn ' t go into infinite loop expanding + ( ... )
expressions .
file - setup: file 644 "abc"
time - limit: 3
stdin:
echo + ( ) c
echo + ( ) x
echo + ( * ) c
echo + ( * ) x
expected - stdout:
+ ( ) c
+ ( ) x
abc
+ ( * ) x
- - -
name: eglob - subst - 1
description:
Check that eglobbing isn ' t done on substitution results
file - setup: file 644 "abc"
stdin:
x = '@(*)'
echo $ x
expected - stdout:
@ ( * )
- - -
name: eglob - nomatch - 1
description:
Check that the pattern doesn ' t match
stdin:
echo 1 : no - file + ( a | b ) stuff
echo 2 : no - file + ( a * ( c ) | b ) stuff
echo 3 : no - file + ( ( ( ( c ) ) ) | b ) stuff
expected - stdout:
1 : no - file + ( a | b ) stuff
2 : no - file + ( a * ( c ) | b ) stuff
3 : no - file + ( ( ( ( c ) ) ) | b ) stuff
- - -
name: eglob - match - 1
description:
Check that the pattern matches correctly
file - setup: file 644 "abd"
file - setup: file 644 "acd"
file - setup: file 644 "abac"
stdin:
echo 1 : a + ( b | c ) d
echo 2 : a ! ( @ ( b | B ) ) d
echo 3 : * ( a ( b | c ) ) # (...|...) can be used within X(..)
echo 4 : a [ b * ( foo | bar ) ] d # patterns not special inside [...]
expected - stdout:
1 : abd acd
2 : acd
3 : abac
4 : abd
- - -
name: eglob - case - 1
description:
Simple negation tests
stdin:
case foo in ! ( foo | bar ) ) echo yes ; ; * ) echo no ; ; esac
case bar in ! ( foo | bar ) ) echo yes ; ; * ) echo no ; ; esac
expected - stdout:
no
no
- - -
name: eglob - case - 2
description:
Simple kleene tests
stdin:
case foo in * ( a | b [ ) ) echo yes ; ; * ) echo no ; ; esac
case foo in * ( a | b [ ) | f * ) echo yes ; ; * ) echo no ; ; esac
case '*(a|b[)' in * ( a | b [ ) ) echo yes ; ; * ) echo no ; ; esac
expected - stdout:
no
yes
yes
- - -
name: eglob - trim - 1
description:
2008-02-27 11:24:12 +00:00
Eglobbing in trim expressions ...
2009-06-11 12:42:21 +00:00
( AT & T ksh fails this - docs say # matches shortest string, ## matches
2005-05-23 03:06:10 +00:00
longest ... )
stdin:
x = abcdef
echo 1 : $ { x #a|abc}
echo 2 : $ { x ##a|abc}
echo 3 : $ { x % def | f }
echo 4 : $ { x %% f | def }
expected - stdout:
1 : bcdef
2 : def
3 : abcde
4 : abc
- - -
name: eglob - trim - 2
description:
2008-02-27 11:24:12 +00:00
Check eglobbing works in trims ...
2005-05-23 03:06:10 +00:00
stdin:
x = abcdef
echo 1 : $ { x #*(a|b)cd}
echo 2 : "${x#*(a|b)cd}"
echo 3 : $ { x #"*(a|b)cd"}
echo 4 : $ { x #a(b|c)}
expected - stdout:
1 : ef
2 : ef
3 : abcdef
4 : cdef
- - -
2011-03-28 21:18:00 +00:00
name: eglob - trim - 3
2011-03-28 08:40:42 +00:00
description:
Check eglobbing works in trims , for Korn Shell
2011-03-28 21:18:00 +00:00
Ensure eglobbing does not work for reduced - feature /bin/s h
2011-03-28 08:40:42 +00:00
stdin:
2011-03-28 21:18:00 +00:00
set + o sh
2011-03-28 08:40:42 +00:00
x = foobar
y = foobaz
2011-07-26 16:57:28 +00:00
z = fooba \ ?
echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2011-03-28 08:40:42 +00:00
echo "<${x%ba(r|z)},${y%ba(r|z)}>"
set - o sh
2011-07-26 16:57:28 +00:00
echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2011-03-28 08:40:42 +00:00
z = 'foo(bar'
echo "<${z%(*}>"
expected - stdout:
2011-07-26 16:57:28 +00:00
<foo,foo,fooba>
2011-03-28 21:18:00 +00:00
<foo,foo>
2011-07-26 16:57:28 +00:00
<foobar,foobaz,fooba>
2011-03-28 08:40:42 +00:00
<foo>
- - -
2008-02-27 11:24:12 +00:00
name: eglob - substrpl - 1
description:
Check eglobbing works in substs ... and they work at all
stdin:
2008-03-01 21:24:58 +00:00
[ [ - n $ BASH_VERSION ] ] && shopt - s extglob
2008-02-27 11:24:12 +00:00
x = 1222321 _ab /cde_b/c _1221
2008-03-01 21:24:58 +00:00
y = xyz
2008-02-27 11:24:12 +00:00
echo 1 : $ { x / 2 }
echo 2 : $ { x // 2 }
echo 3 : $ { x / + ( 2 ) }
echo 4 : $ { x // + ( 2 ) }
echo 5 : $ { x /2/ 4 }
echo 6 : $ { x // 2 / 4 }
echo 7 : $ { x /+(2)/ 4 }
echo 8 : $ { x // + ( 2 ) / 4 }
echo 9 : $ { x /b/c /e/ f }
echo 10 : $ { x /b\/c/ e / f }
echo 11 : $ { x /b\/c/ e \ / f }
echo 12 : $ { x /b\/c/ e \ \ / f }
echo 13 : $ { x /b\\/c /e\\/ f }
echo 14 : $ { x // b /c/ e / f }
echo 15 : $ { x // b \ /c/ e / f }
echo 16 : $ { x // b \ /c/ e \ / f }
echo 17 : $ { x // b \ /c/ e \ \ / f }
echo 18 : $ { x // b \ \ /c/ e \ \ / f }
echo 19 : $ { x /b\/*\/c/x }
echo 20 : $ { x /\// . }
echo 21 : $ { x // \ // . }
echo 22 : $ { x // / . }
2015-12-12 22:25:15 +00:00
echo 23 : $ { x /#1/ 9 }
echo 24 : $ { x // #1/9}
echo 25 : $ { x /%1/ 9 }
echo 26 : $ { x // % 1 / 9 }
echo 27 : $ { x // \ % 1 / 9 }
echo 28 : $ { x // \ \ % 1 / 9 }
echo 29 : $ { x // \ a / 9 }
echo 30 : $ { x // \ \ a / 9 }
echo 31 : $ { x /2/ $ y }
2008-02-27 11:24:12 +00:00
expected - stdout:
1 : 122321 _ab /cde_b/c _1221
2 : 131 _ab /cde_b/c _11
3 : 1321 _ab /cde_b/c _1221
4 : 131 _ab /cde_b/c _11
5 : 1422321 _ab /cde_b/c _1221
6 : 1444341 _ab /cde_b/c _1441
7 : 14321 _ab /cde_b/c _1221
8 : 14341 _ab /cde_b/c _141
9 : 1222321 _ac /e/ f /cde_b/c _1221
10 : 1222321 _ae /fde_b/c _1221
11 : 1222321 _ae /fde_b/c _1221
12 : 1222321 _ae \ /fde_b/c _1221
13 : 1222321 _ab /cde_b/c _1221
14 : 1222321 _ac /e/ f /cde_c/ e /f/c _1221
15 : 1222321 _ae /fde_e/ f_1221
16 : 1222321 _ae /fde_e/ f_1221
17 : 1222321 _ae \ / fde_e \ / f_1221
18 : 1222321 _ab /cde_b/c _1221
19 : 1222321 _ax_1221
20 : 1222321 _ab . cde_b / c_1221
21 : 1222321 _ab . cde_b . c_1221
22 : 1222321 _ab /cde_b/c _1221
23 : 9222321 _ab /cde_b/c _1221
2015-12-12 22:25:15 +00:00
24 : 1222321 _ab /cde_b/c _1221
2008-02-27 11:24:12 +00:00
25 : 1222321 _ab /cde_b/c _1229
2008-02-27 12:49:54 +00:00
26 : 1222321 _ab /cde_b/c _1221
2015-12-12 22:25:15 +00:00
27 : 1222321 _ab /cde_b/c _1221
28 : 1222321 _ab /cde_b/c _1221
29 : 1222321_9 b /cde_b/c _1221
30 : 1222321 _ab /cde_b/c _1221
31 : 1 xyz22321_ab /cde_b/c _1221
2008-02-27 11:24:12 +00:00
- - -
2008-03-01 16:40:57 +00:00
name: eglob - substrpl - 2
description:
Check anchored substring replacement works , corner cases
stdin:
foo = 123
echo 1 : $ { foo /#/x }
echo 2 : $ { foo /%/x }
echo 3 : $ { foo /#/ }
echo 4 : $ { foo / #}
echo 5 : $ { foo /%/ }
echo 6 : $ { foo / % }
expected - stdout:
1 : x123
2 : 123 x
3 : 123
4 : 123
5 : 123
6 : 123
- - -
2008-03-01 21:10:26 +00:00
name: eglob - substrpl - 3 a
2008-03-01 16:40:57 +00:00
description:
Check substring replacement works with variables and slashes , too
stdin:
2015-12-12 22:25:15 +00:00
HOME = / etc
2008-03-01 16:40:57 +00:00
pfx = /home/ user
wd = /home/ user / tmp
2009-07-19 11:03:18 +00:00
echo "${wd/#$pfx/~}"
echo "${wd/#\$pfx/~}"
echo "${wd/#" $ pfx "/~}"
echo "${wd/#'$pfx'/~}"
echo "${wd/#" \ $ pfx "/~}"
echo "${wd/#'\$pfx'/~}"
2008-03-01 21:10:26 +00:00
expected - stdout:
2015-12-12 22:25:15 +00:00
/etc/ tmp
2008-03-01 21:10:26 +00:00
/home/ user / tmp
2015-12-12 22:25:15 +00:00
/etc/ tmp
2008-03-01 21:10:26 +00:00
/home/ user / tmp
/home/ user / tmp
/home/ user / tmp
- - -
name: eglob - substrpl - 3 b
description:
2009-07-19 11:03:18 +00:00
More of this , bash fails it ( bash4 passes )
2008-03-01 21:10:26 +00:00
stdin:
2015-12-12 22:25:15 +00:00
HOME = / etc
2008-03-01 21:10:26 +00:00
pfx = /home/ user
wd = /home/ user / tmp
2009-07-19 11:03:18 +00:00
echo "${wd/#$(echo /home/user)/~}"
echo "${wd/#" $ ( echo /home/ user ) "/~}"
echo "${wd/#'$(echo /home/user)'/~}"
2008-03-01 16:40:57 +00:00
expected - stdout:
2015-12-12 22:25:15 +00:00
/etc/ tmp
/etc/ tmp
2008-03-01 17:14:17 +00:00
/home/ user / tmp
2008-03-01 16:40:57 +00:00
- - -
2008-03-01 21:10:26 +00:00
name: eglob - substrpl - 3 c
description:
Even more weird cases
stdin:
2015-12-12 22:25:15 +00:00
HOME = / etc
2008-03-01 21:10:26 +00:00
pfx = /home/ user
wd = '$pfx/tmp'
2008-03-01 22:58:22 +00:00
echo 1 : $ { wd /#$pfx/ ~ }
echo 2 : $ { wd /#\$pfx/ ~ }
echo 3 : $ { wd /#"$pfx"/ ~ }
echo 4 : $ { wd /#'$pfx'/ ~ }
echo 5 : $ { wd /#"\$pfx"/ ~ }
echo 6 : $ { wd /#'\$pfx'/ ~ }
ts = 'a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
tp = a / b
tr = c / d
[ [ - n $ BASH_VERSION ] ] && shopt - s extglob
echo 7 : $ { ts /a\/b/ $ tr }
echo 8 : $ { ts /a\/b/ \ $ tr }
echo 9 : $ { ts /$tp/ $ tr }
echo 10 : $ { ts /\$tp/ $ tr }
echo 11 : $ { ts /\\$tp/ $ tr }
echo 12 : $ { ts /$tp/c / d }
echo 13 : $ { ts /$tp/c \ / d }
echo 14 : $ { ts /$tp/c \ \ / d }
echo 15 : $ { ts /+(a\/b)/ $ tr }
echo 16 : $ { ts /+(a\/b)/ \ $ tr }
echo 17 : $ { ts /+($tp)/ $ tr }
echo 18 : $ { ts /+($tp)/c / d }
echo 19 : $ { ts /+($tp)/c \ / d }
2015-12-12 22:25:15 +00:00
echo 20 : $ { ts // a \ /b/ $ tr }
echo 21 : $ { ts // a \ /b/ \ $ tr }
echo 22 : $ { ts // $ tp / $ tr }
echo 23 : $ { ts // $ tp /c/ d }
echo 24 : $ { ts // $ tp / c \ / d }
echo 25 : $ { ts // + ( a \ /b)/ $ tr }
echo 26 : $ { ts // + ( a \ /b)/ \ $ tr }
echo 27 : $ { ts // + ( $ tp ) / $ tr }
echo 28 : $ { ts // + ( $ tp ) /c/ d }
echo 29 : $ { ts // + ( $ tp ) / c \ / d }
2008-03-01 22:58:22 +00:00
tp = "+($tp)"
2015-12-12 22:25:15 +00:00
echo 30 : $ { ts /$tp/ $ tr }
echo 31 : $ { ts // $ tp / $ tr }
2008-03-01 21:10:26 +00:00
expected - stdout:
2008-03-01 22:58:22 +00:00
1 : $ pfx / tmp
2015-12-12 22:25:15 +00:00
2 : /etc/ tmp
2008-03-01 22:58:22 +00:00
3 : $ pfx / tmp
2015-12-12 22:25:15 +00:00
4 : /etc/ tmp
5 : /etc/ tmp
6 : $ pfx / tmp
2008-03-01 22:58:22 +00:00
7 : c /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
8 : $ tra /b$tp$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
9 : c /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
10 : a /ba/ bc /d$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
2015-12-12 22:25:15 +00:00
11 : a /ba/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
2008-03-01 22:58:22 +00:00
12 : c /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
13 : c /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
14 : c \ /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
15 : c /d$tp$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
16 : $ tr $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
17 : c /d$tp$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
18 : c /d$tp$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
19 : c /d$tp$tp_a/ b $ tp_ * ( a / b ) _ * ( $ tp )
2015-12-12 22:25:15 +00:00
20 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
21 : $ tr $ tr $ tp $ tp_ $ tr $ tp_ * ( $ tr ) _ * ( $ tp )
22 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
23 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
24 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
25 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
26 : $ tr $ tp $ tp_ $ tr $ tp_ * ( $ tr ) _ * ( $ tp )
27 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
28 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
29 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
30 : a /ba/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
31 : a /ba/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
2008-03-01 22:58:22 +00:00
# This is what GNU bash does:
2015-12-12 22:25:15 +00:00
# 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
# 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2008-03-01 21:10:26 +00:00
- - -
2009-11-21 22:30:36 +00:00
name: eglob - utf8 - 1
description:
UTF - 8 mode differences for eglobbing
stdin:
s = blöd
set + U
print 1 : $ { s % ? ? ? } .
print 2 : $ { s /b???d/x } .
set - U
print 3 : $ { s % ? ? ? } .
print 4 : $ { s /b??d/x } .
x = nö
print 5 : $ { x % ? } $ { x %% ? } .
x = äh
print 6 : $ { x #?} ${x##?} .
x = <EFBFBD> <EFBFBD>
print 7 : $ { x % ? } $ { x %% ? } .
x = mä <EFBFBD>
print 8 : $ { x % ? } $ { x %% ? } .
x = 何
print 9 : $ { x % ? } $ { x %% ? } .
expected - stdout:
1 : bl .
2 : x .
3 : b .
4 : x .
5 : n n .
6 : h h .
2009-11-21 22:32:08 +00:00
7 : <EFBFBD> <EFBFBD> .
2009-11-21 22:30:36 +00:00
8 : mä mä .
9 : .
- - -
2005-05-23 03:06:10 +00:00
name: glob - bad - 1
description:
Check that globbing isn ' t done when glob has syntax error
file - setup: dir 755 "[x"
file - setup: file 644 "[x/foo"
stdin:
echo [ *
echo * [ x
echo [ x / *
expected - stdout:
[ *
* [ x
[ x / foo
- - -
name: glob - bad - 2
description:
Check that symbolic links aren 't stat()' d
2012-04-06 12:27:15 +00:00
# breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2015-07-09 19:28:21 +00:00
# breaks on FreeMiNT (cannot unlink dangling symlinks)
# breaks on MSYS, OS/2 (do not support symlinks)
2012-05-04 21:42:51 +00:00
category: ! os:mint , ! os:msys , ! os:svr4 .0 , ! nosymlink
2005-05-23 03:06:10 +00:00
file - setup: dir 755 "dir"
file - setup: symlink 644 "dir/abc"
non - existent - file
stdin:
echo d * / *
echo d * / abc
expected - stdout:
dir / abc
dir / abc
- - -
name: glob - range - 1
description:
Test range matching
file - setup: file 644 ".bc"
file - setup: file 644 "abc"
file - setup: file 644 "bbc"
file - setup: file 644 "cbc"
file - setup: file 644 "-bc"
stdin:
echo [ ab - ] *
echo [ - ab ] *
echo [ ! - ab ] *
echo [ ! ab ] *
echo [] ab ] *
2014-01-11 18:09:43 +00:00
: > './!bc'
: > './^bc'
echo [ ^ ab ] *
echo [ ! ab ] *
2005-05-23 03:06:10 +00:00
expected - stdout:
- bc abc bbc
- bc abc bbc
cbc
- bc cbc
abc bbc
2014-01-11 18:09:43 +00:00
^ bc abc bbc
! bc - bc ^ bc cbc
2005-05-23 03:06:10 +00:00
- - -
name: glob - range - 2
description:
Test range matching
2009-06-11 12:42:21 +00:00
( AT & T ksh fails this ; POSIX says invalid )
2005-05-23 03:06:10 +00:00
file - setup: file 644 "abc"
stdin:
echo [ a - - ] *
expected - stdout:
[ a - - ] *
- - -
name: glob - range - 3
description:
Check that globbing matches the right things ...
2007-04-23 21:46:12 +00:00
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2011-05-29 16:31:42 +00:00
# breaks on Cygwin 1.7 (files are now UTF-16 or something)
2012-12-24 14:37:13 +00:00
# breaks on QNX 6.4.1 (says RT)
2015-07-09 19:28:21 +00:00
category: ! os:cygwin , ! os:darwin , ! os:msys , ! os:nto , ! os:os2
2012-12-28 03:18:46 +00:00
need - pass: no
2005-05-23 03:06:10 +00:00
file - setup: file 644 "a<> c"
stdin:
echo a [ <EFBFBD> - <EFBFBD> ] *
expected - stdout:
a <EFBFBD> c
- - -
name: glob - range - 4
description:
Results unspecified according to POSIX
file - setup: file 644 ".bc"
stdin:
echo [ a . ] *
expected - stdout:
[ a . ] *
- - -
name: glob - range - 5
description:
Results unspecified according to POSIX
2009-06-11 12:42:21 +00:00
( AT & T ksh treats this like [ a - cc - e ] * )
2005-05-23 03:06:10 +00:00
file - setup: file 644 "abc"
file - setup: file 644 "bbc"
file - setup: file 644 "cbc"
file - setup: file 644 "dbc"
file - setup: file 644 "ebc"
file - setup: file 644 "-bc"
stdin:
echo [ a - c - e ] *
expected - stdout:
- bc abc bbc cbc ebc
- - -
2013-11-30 00:20:48 +00:00
name: glob - trim - 1
description:
Check against a regression from fixing IFS - subst - 2
stdin:
x = '#foo'
print - r "before='$x'"
x = $ { x %%# * }
print - r "after ='$x'"
expected - stdout:
before = '#foo'
after = ''
- - -
2005-05-23 03:06:10 +00:00
name: heredoc - 1
description:
Check ordering / content of redundent here documents .
stdin:
2005-07-07 23:27:52 +00:00
cat << EOF1 << EOF2
2005-05-23 03:06:10 +00:00
hi
EOF1
there
EOF2
expected - stdout:
there
- - -
name: heredoc - 2
description:
Check quoted here - doc is protected .
stdin:
a = foo
cat << 'EOF'
hi \
there $ a
stuff
EO \
F
EOF
expected - stdout:
hi \
there $ a
stuff
EO \
F
- - -
name: heredoc - 3
description:
Check that newline isn ' t needed after heredoc - delimiter marker .
stdin: !
cat << EOF
hi
there
EOF
expected - stdout:
hi
there
- - -
name: heredoc - 4
description:
Check that an error occurs if the heredoc - delimiter is missing .
stdin: !
cat << EOF
hi
there
expected - exit : e > 0
expected - stderr - pattern: /.*/
- - -
name: heredoc - 5
description:
Check that backslash quotes a $, ` and \ and kills a \ newline
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
a = BAD
b = ok
cat << EOF
h \ $ { a } i
h \ \ $ { b } i
th \ ` echo not - run \ ` ere
th \ \ `echo is-run` ere
fol \ \ ks
more \ \
last \
line
EOF
expected - stdout:
h $ { a } i
h \ oki
th `echo not-run` ere
th \ is - runere
fol \ ks
more \
last line
- - -
name: heredoc - 6
description:
Check that \ newline in initial here - delim word doesn ' t imply
a quoted here - doc .
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
a = i
cat << EO \
F
h $ a
there
EOF
expected - stdout:
hi
there
- - -
name: heredoc - 7
description:
Check that double quoted $ expressions in here delimiters are
not expanded and match the delimiter .
POSIX says only quote removal is applied to the delimiter .
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
a = b
cat << "E$a"
hi
h $ a
hb
E $ a
echo done
expected - stdout:
hi
h $ a
hb
done
- - -
name: heredoc - 8
description:
Check that double quoted escaped $ expressions in here
delimiters are not expanded and match the delimiter .
POSIX says only quote removal is applied to the delimiter
( \ counts as a quote ) .
2005-07-07 23:27:52 +00:00
stdin:
2005-05-23 03:06:10 +00:00
a = b
cat << "E\$a"
hi
h $ a
h \ $ a
hb
h \ b
E $ a
echo done
expected - stdout:
hi
h $ a
h \ $ a
hb
h \ b
done
- - -
2008-02-26 20:43:11 +00:00
name: heredoc - 9 a
description:
Check that here strings work .
stdin:
bar = " bar
baz "
2008-02-29 16:38:41 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < foo
2008-04-01 16:04:58 +00:00
"$__progname" - c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2008-02-29 16:38:41 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < "$bar"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < '$bar'
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < \ $ bar
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < - foo
2013-01-19 18:32:56 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < "$(echo " foo bar ")"
2015-09-06 19:47:01 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < "A $(echo " foo bar ") B"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < \ $ b \ $ b $ bar
2008-02-26 20:43:11 +00:00
expected - stdout:
sbb
sbb
one
onm
$ one
$ one
- sbb
2013-01-19 18:32:56 +00:00
sbb one
2015-09-06 19:47:01 +00:00
A sbb one B
$ o $ oone
onm
2008-02-26 20:43:11 +00:00
- - -
name: heredoc - 9 b
description:
Check that a corner case of here strings works like bash
stdin:
fnord = 42
bar = " bar
\ $ fnord baz "
2008-02-29 16:38:41 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < $ bar
2008-02-26 20:43:11 +00:00
expected - stdout:
one $ sabeq onm
category: bash
- - -
name: heredoc - 9 c
description:
Check that a corner case of here strings works like ksh93 , zsh
stdin:
fnord = 42
bar = " bar
\ $ fnord baz "
2008-02-29 16:38:41 +00:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < $ bar
2008-02-26 20:43:11 +00:00
expected - stdout:
one
$ sabeq onm
- - -
2008-07-09 20:31:19 +00:00
name: heredoc - 9 d
description:
Check another corner case of here strings
stdin:
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < bar
expected - stdout:
one
- - -
2011-05-07 00:02:26 +00:00
name: heredoc - 9 e
description:
Check here string related regression with multiple iops
stdin:
2013-02-10 19:04:00 +00:00
echo $ ( tr r z << < 'bar' 2 > /dev/ null )
2011-05-07 00:02:26 +00:00
expected - stdout:
baz
- - -
2014-12-15 22:50:11 +00:00
name: heredoc - 9 f
description:
Check long here strings
stdin:
cat << < "$( : )aa"
expected - stdout:
aa
- - -
2011-01-09 21:57:29 +00:00
name: heredoc - 10
description:
Check direct here document assignment
stdin:
x = u
va = << EOF
= a $ x \ x40 =
EOF
vb = << 'EOF'
= b $ x \ x40 =
EOF
function foo {
vc = << - EOF
= c $ x \ x40 =
EOF
}
2012-07-30 19:58:05 +00:00
fnd = $ ( typeset - f foo )
print - r - - "$fnd"
function foo {
echo blub
}
foo
eval "$fnd"
2011-01-09 21:57:29 +00:00
foo
# rather nonsensical, but…
vd = << < "=d $x \x40="
ve = << < '=e $x \x40='
vf = << < $' = f $ x \ x40 = '
# now check
print - r - - "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2014-10-12 19:55:01 +00:00
# check append
v = << - EOF
vapp1
EOF
v += << - EOF
vapp2
EOF
print - r - - "| ${v//$'\n'/^} |"
2011-01-09 21:57:29 +00:00
expected - stdout:
function foo {
2015-09-05 20:20:48 +00:00
vc = << - EOF
2011-01-09 21:57:29 +00:00
= c $ x \ x40 =
EOF
}
2012-07-30 19:58:05 +00:00
blub
2011-01-09 21:57:29 +00:00
| va = { = a u \ x40 =
} vb = { = b $ x \ x40 =
} vc = { = c u \ x40 =
} vd = { = d u \ x40 =
} ve = { = e $ x \ x40 =
} vf = { = f $ x @ =
} |
2014-10-12 19:55:01 +00:00
| vapp1 ^ vapp2 ^ |
2011-01-09 21:57:29 +00:00
- - -
2011-05-05 00:05:01 +00:00
name: heredoc - 11
description:
Check here documents with no or empty delimiter
stdin:
x = u
va = <<
= a $ x \ x40 =
<<
vb = << ''
= b $ x \ x40 =
function foo {
vc = << -
= c $ x \ x40 =
<<
vd = << - ''
= d $ x \ x40 =
}
2012-07-30 19:58:05 +00:00
fnd = $ ( typeset - f foo )
print - r - - "$fnd"
function foo {
echo blub
}
foo
eval "$fnd"
2011-05-05 00:05:01 +00:00
foo
print - r - - "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2014-10-12 19:55:01 +00:00
# check append
v = << -
vapp1
<<
v += << - ''
vapp2
print - r - - "| ${v//$'\n'/^} |"
2011-05-05 00:05:01 +00:00
expected - stdout:
function foo {
2015-09-05 20:20:48 +00:00
vc = << -
2011-05-05 00:05:01 +00:00
= c $ x \ x40 =
<<
2015-09-05 20:20:48 +00:00
vd = << - ""
2011-05-05 00:05:01 +00:00
= d $ x \ x40 =
}
2012-07-30 19:58:05 +00:00
blub
2011-05-05 00:05:01 +00:00
| va = { = a u \ x40 =
} vb = { = b $ x \ x40 =
} vc = { = c u \ x40 =
} vd = { = d $ x \ x40 =
} |
2014-10-12 19:55:01 +00:00
| vapp1 ^ vapp2 ^ |
2011-05-05 00:05:01 +00:00
- - -
2015-02-19 22:26:50 +00:00
name: heredoc - 12
description:
Check here documents can use $* and $@ ; note shells vary:
• pdksh 5.2 .14 acts the same
• dash has 1 and 2 the same but 3 lacks the space
• ksh93 , bash4 differ in 2 by using space ipv colon
stdin:
set - - a b
nl = '
'
IFS = " $nl" ; n = 1
cat << EOF
$ n foo $* foo
$ n bar "$*" bar
$ n baz $@ baz
$ n bla "$@" bla
EOF
IFS = ":" ; n = 2
cat << EOF
$ n foo $* foo
$ n bar "$*" bar
$ n baz $@ baz
$ n bla "$@" bla
EOF
IFS = ; n = 3
cat << EOF
$ n foo $* foo
$ n bar "$*" bar
$ n baz $@ baz
$ n bla "$@" bla
EOF
expected - stdout:
1 foo a b foo
1 bar "a b" bar
1 baz a b baz
1 bla "a b" bla
2 foo a:b foo
2 bar "a:b" bar
2 baz a:b baz
2 bla "a:b" bla
3 foo a b foo
3 bar "a b" bar
3 baz a b baz
3 bla "a b" bla
- - -
2015-09-05 20:20:48 +00:00
name: heredoc - 14
description:
Check that using multiple here documents works
stdin:
foo ( ) {
echo "got $(cat) on stdin"
echo "got $(cat <&4) on fd#4"
echo "got $(cat <&5) on fd#5"
}
bar ( ) {
foo 4 << - a << - b 5 << - c
four
a
zero
b
five
c
}
x = $ ( typeset - f bar )
eval "$x"
y = $ ( typeset - f bar )
[ [ $ x = "$y" ] ] ; echo $?
typeset - f bar
bar
expected - stdout:
0
bar ( ) {
foo 4 << - a << - b 5 << - c
four
a
zero
b
five
c
}
got zero on stdin
got four on fd #4
got five on fd #5
- - -
2011-03-26 15:32:37 +00:00
name: heredoc - comsub - 1
description:
Tests for here documents in COMSUB , taken from Austin ML
stdin:
text = $ ( cat << EOF
here is the text
EOF )
echo = $ text =
expected - stdout:
= here is the text =
- - -
name: heredoc - comsub - 2
description:
Tests for here documents in COMSUB , taken from Austin ML
stdin:
unbalanced = $ ( cat << EOF
this paren ) is a problem
EOF )
echo = $ unbalanced =
expected - stdout:
= this paren ) is a problem =
- - -
name: heredoc - comsub - 3
description:
Tests for here documents in COMSUB , taken from Austin ML
stdin:
balanced = $ ( cat << EOF
these parens ( ) are not a problem
EOF )
echo = $ balanced =
expected - stdout:
= these parens ( ) are not a problem =
- - -
name: heredoc - comsub - 4
description:
Tests for here documents in COMSUB , taken from Austin ML
stdin:
balanced = $ ( cat << EOF
these parens \ ( ) are a problem
EOF )
echo = $ balanced =
expected - stdout:
= these parens \ ( ) are a problem =
- - -
name: heredoc - subshell - 1
description:
Tests for here documents in subshells , taken from Austin ML
stdin:
( cat << EOF
some text
EOF )
echo end
expected - stdout:
some text
end
- - -
name: heredoc - subshell - 2
description:
Tests for here documents in subshells , taken from Austin ML
stdin:
( cat << EOF
some text
EOF
)
echo end
expected - stdout:
some text
end
- - -
name: heredoc - subshell - 3
description:
Tests for here documents in subshells , taken from Austin ML
stdin:
( cat << EOF ; )
some text
EOF
echo end
expected - stdout:
some text
end
- - -
name: heredoc - weird - 1
description:
Tests for here documents , taken from Austin ML
Documents current state in mksh , * NOT * necessarily correct !
stdin:
cat << END
hello
END \
END
END
echo end
expected - stdout:
hello
ENDEND
end
- - -
name: heredoc - weird - 2
description:
Tests for here documents , taken from Austin ML
stdin:
cat << ' END '
hello
END
echo end
expected - stdout:
hello
end
- - -
name: heredoc - weird - 4
description:
Tests for here documents , taken from Austin ML
Documents current state in mksh , * NOT * necessarily correct !
stdin:
cat << END
hello \
END
END
echo end
expected - stdout:
helloEND
end
- - -
name: heredoc - weird - 5
description:
Tests for here documents , taken from Austin ML
Documents current state in mksh , * NOT * necessarily correct !
stdin:
cat << END
hello
\ END
END
echo end
expected - stdout:
hello
\ END
end
- - -
2005-05-23 03:06:10 +00:00
name: heredoc - tmpfile - 1
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Heredoc in simple command .
stdin:
TMPDIR = $ PWD
eval '
cat << - EOF
hi
EOF
for i in a b ; do
cat << - EOF
more
EOF
done
' &
sleep 1
echo Left overs: *
expected - stdout:
hi
more
more
Left overs: *
- - -
name: heredoc - tmpfile - 2
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Heredoc in function , multiple calls to function .
stdin:
TMPDIR = $ PWD
eval '
foo ( ) {
cat << - EOF
hi
EOF
}
foo
foo
' &
sleep 1
echo Left overs: *
expected - stdout:
hi
hi
Left overs: *
- - -
name: heredoc - tmpfile - 3
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Heredoc in function in loop , multiple calls to function .
stdin:
TMPDIR = $ PWD
eval '
foo ( ) {
cat << - EOF
hi
EOF
}
for i in a b ; do
foo
foo ( ) {
cat << - EOF
folks $ i
EOF
}
done
foo
' &
sleep 1
echo Left overs: *
expected - stdout:
hi
folks b
folks b
Left overs: *
- - -
name: heredoc - tmpfile - 4
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Backgrounded simple command with here doc
stdin:
TMPDIR = $ PWD
eval '
cat << - EOF &
hi
EOF
' &
sleep 1
echo Left overs: *
expected - stdout:
hi
Left overs: *
- - -
name: heredoc - tmpfile - 5
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Backgrounded subshell command with here doc
stdin:
TMPDIR = $ PWD
eval '
(
sleep 1 # so parent exits
echo A
cat << - EOF
hi
EOF
echo B
) &
' &
sleep 2
echo Left overs: *
expected - stdout:
A
hi
B
Left overs: *
- - -
name: heredoc - tmpfile - 6
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Heredoc in pipeline .
stdin:
TMPDIR = $ PWD
eval '
cat << - EOF | sed "s/hi/HI/"
hi
EOF
' &
sleep 1
echo Left overs: *
expected - stdout:
HI
Left overs: *
- - -
name: heredoc - tmpfile - 7
description:
Check that heredoc temp files aren ' t removed too soon or too late .
Heredoc in backgrounded pipeline .
stdin:
TMPDIR = $ PWD
eval '
cat << - EOF | sed 's/hi/HI/' &
hi
EOF
' &
sleep 1
echo Left overs: *
expected - stdout:
HI
Left overs: *
- - -
name: heredoc - tmpfile - 8
description:
2008-12-08 13:57:35 +00:00
Check that heredoc temp files aren ' t removed too soon or too
late . Heredoc in function , backgrounded call to function .
This check can fail on slow machines ( < 100 MHz ) , or Cygwin ,
that ' s normal .
2011-05-29 16:31:42 +00:00
need - pass: no
2005-05-23 03:06:10 +00:00
stdin:
TMPDIR = $ PWD
# Background eval so main shell doesn't do parsing
eval '
foo ( ) {
cat << - EOF
hi
EOF
}
foo
# sleep so eval can die
( sleep 1 ; foo ) &
( sleep 1 ; foo ) &
foo
' &
sleep 2
echo Left overs: *
expected - stdout:
hi
hi
hi
hi
Left overs: *
- - -
2013-06-01 00:15:58 +00:00
name: heredoc - quoting - unsubst
description:
Check for correct handling of quoted characters in
here documents without substitution ( marker is quoted ) .
stdin:
foo = bar
cat << - 'EOF'
x " \ " \ \ \ $ \ $ ` echo baz ` \ ` echo baz \ ` $ foo \ $ foo x
EOF
expected - stdout:
x " \ " \ \ \ $ \ $ ` echo baz ` \ ` echo baz \ ` $ foo \ $ foo x
- - -
name: heredoc - quoting - subst
description:
Check for correct handling of quoted characters in
here documents with substitution ( marker is not quoted ) .
stdin:
foo = bar
cat << - EOF
x " \ " \ \ \ $ \ $ ` echo baz ` \ ` echo baz \ ` $ foo \ $ foo x
EOF
expected - stdout:
x " \ " \ \ $ $ baz `echo baz` bar $ foo x
- - -
name: single - quotes - in - braces
description:
Check that single quotes inside unquoted { } are treated as quotes
stdin:
foo = 1
echo $ { foo: + 'blah $foo' }
expected - stdout:
blah $ foo
- - -
name: single - quotes - in - quoted - braces
description:
Check that single quotes inside quoted { } are treated as
normal char
stdin:
foo = 1
echo "${foo:+'blah $foo'}"
expected - stdout:
'blah 1'
- - -
name: single - quotes - in - braces - nested
description:
Check that single quotes inside unquoted { } are treated as quotes ,
even if that ' s inside a double - quoted command expansion
stdin:
foo = 1
echo "$( echo ${foo:+'blah $foo'})"
expected - stdout:
blah $ foo
- - -
name: single - quotes - in - brace - pattern
description:
Check that single quotes inside { } pattern are treated as quotes
stdin:
foo = 1234
echo $ { foo % ' 2 '*} "${foo%' 2 '*}" ${foo%2' * '} "${foo%2' * ' } "
expected - stdout:
1 1 1234 1234
- - -
name: single - quotes - in - heredoc - braces
description:
Check that single quotes inside { } in heredoc are treated
as normal char
stdin:
foo = 1
cat << EOM
$ { foo: + 'blah $foo' }
EOM
expected - stdout:
'blah 1'
- - -
name: single - quotes - in - nested - braces
description:
Check that single quotes inside nested unquoted { } are
treated as quotes
stdin:
foo = 1
echo $ { foo: + $ { foo: + 'blah $foo' } }
expected - stdout:
blah $ foo
- - -
name: single - quotes - in - nested - quoted - braces
description:
Check that single quotes inside nested quoted { } are treated
as normal char
stdin:
foo = 1
echo "${foo:+${foo:+'blah $foo'}}"
expected - stdout:
'blah 1'
- - -
name: single - quotes - in - nested - braces - nested
description:
Check that single quotes inside nested unquoted { } are treated
as quotes , even if that ' s inside a double - quoted command expansion
stdin:
foo = 1
echo "$( echo ${foo:+${foo:+'blah $foo'}})"
expected - stdout:
blah $ foo
- - -
name: single - quotes - in - nested - brace - pattern
description:
Check that single quotes inside nested { } pattern are treated as quotes
stdin:
foo = 1234
echo $ { foo: + $ { foo % ' 2 '*}} "${foo:+${foo%' 2 '*}}" ${foo:+${foo%2' * '}} "${foo:+${foo%2' * ' } } "
expected - stdout:
1 1 1234 1234
- - -
name: single - quotes - in - heredoc - nested - braces
description:
Check that single quotes inside nested { } in heredoc are treated
as normal char
stdin:
foo = 1
cat << EOM
$ { foo: + $ { foo: + 'blah $foo' } }
EOM
expected - stdout:
'blah 1'
- - -
2005-05-23 03:06:10 +00:00
name: history - basic
description:
See if we can test history at all
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo hi
fc - l
expected - stdout:
hi
1 echo hi
expected - stderr - pattern:
/^X*$/
- - -
2008-09-30 18:43:07 +00:00
name: history - dups
description:
Verify duplicates and spaces are not entered
2011-03-28 21:58:06 +00:00
need - ctty: yes
2008-09-30 18:43:07 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo hi
echo yo
echo hi
fc - l
expected - stdout:
hi
yo
hi
1 echo hi
expected - stderr - pattern:
/^X*$/
- - -
2008-07-06 22:41:09 +00:00
name: history - unlink
description:
Check if broken HISTFILEs do not cause trouble
2011-03-28 21:58:06 +00:00
need - ctty: yes
2008-07-06 22:41:09 +00:00
arguments: ! - i !
env - setup: ! ENV = . /Env!HISTFILE=foo/ hist . file !
file - setup: file 644 "Env"
PS1 = X
file - setup: dir 755 "foo"
file - setup: file 644 "foo/hist.file"
sometext
time - limit: 5
perl - setup: chmod ( 0555 , "foo" ) ;
stdin:
echo hi
fc - l
chmod 0755 foo
expected - stdout:
hi
1 echo hi
expected - stderr - pattern:
2010-08-28 20:22:24 +00:00
/(.*can't unlink HISTFILE.*\n)?X*$/
2008-07-06 22:41:09 +00:00
- - -
2005-05-23 03:06:10 +00:00
name: history - e - minus - 1
description:
Check if more recent command is executed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo hi
echo there
fc - e -
expected - stdout:
hi
there
there
expected - stderr - pattern:
/^X*echo there\nX*$/
- - -
name: history - e - minus - 2
description:
Check that repeated command is printed before command
is re - executed .
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
exec 2 > & 1
echo hi
echo there
fc - e -
expected - stdout - pattern:
/X*hi\nX*there\nX*echo there\nthere\nX*/
expected - stderr - pattern:
/^X*$/
- - -
name: history - e - minus - 3
description:
fc - e - fails when there is no history
( ksh93 has a bug that causes this to fail )
( ksh88 loops on this )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
fc - e -
echo ok
expected - stdout:
ok
expected - stderr - pattern:
/^X*.*:.*history.*\nX*$/
- - -
name: history - e - minus - 4
description:
Check if "fc -e -" command output goes to stdout .
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc
fc - e - | ( read x ; echo "A $x" )
echo ok
expected - stdout:
abc
A abc
ok
expected - stderr - pattern:
/^X*echo abc\nX*/
- - -
name: history - e - minus - 5
description:
fc is replaced in history by new command .
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
echo ghi jkl
2008-09-30 19:36:16 +00:00
:
2005-05-23 03:06:10 +00:00
fc - e - echo
2008-09-30 19:36:16 +00:00
fc - l 2 5
2005-05-23 03:06:10 +00:00
expected - stdout:
abc def
ghi jkl
ghi jkl
2 echo ghi jkl
2008-09-30 19:36:16 +00:00
3 :
4 echo ghi jkl
5 fc - l 2 5
2005-05-23 03:06:10 +00:00
expected - stderr - pattern:
/^X*echo ghi jkl\nX*$/
- - -
name: history - list - 1
description:
List lists correct range
( ksh88 fails ' cause it lists the fc command )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
fc - l - - - 2
expected - stdout:
line 1
line 2
line 3
2 echo line 2
3 echo line 3
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 2
description:
Lists oldest history if given pre - historic number
( ksh93 has a bug that causes this to fail )
( ksh88 fails ' cause it lists the fc command )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
fc - l - - - 40
expected - stdout:
line 1
line 2
line 3
1 echo line 1
2 echo line 2
3 echo line 3
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 3
description:
Can give number 'options' to fc
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc - l - 3 - 2
expected - stdout:
line 1
line 2
line 3
line 4
2 echo line 2
3 echo line 3
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 4
description:
- 1 refers to previous command
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc - l - 1 - 1
expected - stdout:
line 1
line 2
line 3
line 4
4 echo line 4
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 5
description:
List command stays in history
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
fc - l - 1 - 1
fc - l - 2 - 1
expected - stdout:
line 1
line 2
line 3
line 4
4 echo line 4
4 echo line 4
5 fc - l - 1 - 1
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 6
description:
HISTSIZE limits about of history kept .
( ksh88 fails ' cause it lists the fc command )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file ! HISTSIZE = 3 !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc - l
expected - stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
5 echo line 5
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - 7
description:
fc allows too old / new errors in range specification
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file ! HISTSIZE = 3 !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc - l 1 30
expected - stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
5 echo line 5
6 fc - l 1 30
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - r - 1
description:
test - r flag in history
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc - l - r 2 4
expected - stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
3 echo line 3
2 echo line 2
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - r - 2
description:
If first is newer than last , - r is implied .
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc - l 4 2
expected - stdout:
line 1
line 2
line 3
line 4
line 5
4 echo line 4
3 echo line 3
2 echo line 2
expected - stderr - pattern:
/^X*$/
- - -
name: history - list - r - 3
description:
If first is newer than last , - r is cancelled .
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2
echo line 3
echo line 4
echo line 5
fc - l - r 4 2
expected - stdout:
line 1
line 2
line 3
line 4
line 5
2 echo line 2
3 echo line 3
4 echo line 4
expected - stderr - pattern:
/^X*$/
- - -
name: history - subst - 1
description:
Basic substitution
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
echo ghi jkl
fc - e - abc = AB 'echo a'
expected - stdout:
abc def
ghi jkl
AB def
expected - stderr - pattern:
/^X*echo AB def\nX*$/
- - -
name: history - subst - 2
description:
Does subst find previous command ?
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
echo ghi jkl
fc - e - jkl = XYZQRT 'echo g'
expected - stdout:
abc def
ghi jkl
ghi XYZQRT
expected - stderr - pattern:
/^X*echo ghi XYZQRT\nX*$/
- - -
name: history - subst - 3
description:
Does subst find previous command when no arguments given
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
echo ghi jkl
fc - e - jkl = XYZQRT
expected - stdout:
abc def
ghi jkl
ghi XYZQRT
expected - stderr - pattern:
/^X*echo ghi XYZQRT\nX*$/
- - -
name: history - subst - 4
description:
Global substitutions work
( ksh88 and ksh93 do not have - g option )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def asjj sadjhasdjh asdjhasd
fc - e - - g a = FooBAR
expected - stdout:
abc def asjj sadjhasdjh asdjhasd
FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
expected - stderr - pattern:
/^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
- - -
name: history - subst - 5
description:
Make sure searches don ' t find current ( fc ) command
( ksh88 / ksh93 don ' t have the ? prefix thing so they fail this test )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
echo ghi jkl
fc - e - abc = AB \ ? abc
expected - stdout:
abc def
ghi jkl
AB def
expected - stderr - pattern:
/^X*echo AB def\nX*$/
- - -
2005-05-23 16:17:00 +00:00
name: history - ed - 1 - old
description:
Basic ( ed ) editing works ( assumes you have generic ed editor
2005-05-23 16:23:19 +00:00
that prints no prompts ) . This is for oldish ed ( 1 ) which write
2007-01-18 01:10:55 +00:00
the character count to stdout .
2008-11-08 17:36:35 +00:00
category: stdout - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 16:17:00 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
w
q
expected - stdout:
abc def
13
16
FOOBAR def
expected - stderr - pattern:
/^X*echo FOOBAR def\nX*$/
- - -
name: history - ed - 2 - old
description:
Correct command is edited when number given
2008-11-08 17:36:35 +00:00
category: stdout - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 16:17:00 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2 is here
echo line 3
echo line 4
fc 2
s/is here/is changed/
w
q
expected - stdout:
line 1
line 2 is here
line 3
line 4
20
23
line 2 is changed
expected - stderr - pattern:
/^X*echo line 2 is changed\nX*$/
- - -
name: history - ed - 3 - old
description:
Newly created multi line commands show up as single command
in history .
( ksh88 fails ' cause it lists the fc command )
2008-11-08 17:36:35 +00:00
category: stdout - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 16:17:00 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
$ a
echo a new line
.
w
q
fc - l
expected - stdout:
abc def
13
32
FOOBAR def
a new line
1 echo abc def
2 echo FOOBAR def
2015-07-05 17:04:26 +00:00
echo a new line
2005-05-23 16:17:00 +00:00
expected - stderr - pattern:
/^X*echo FOOBAR def\necho a new line\nX*$/
- - -
2005-05-23 03:06:10 +00:00
name: history - ed - 1
description:
Basic ( ed ) editing works ( assumes you have generic ed editor
2005-05-23 16:23:19 +00:00
that prints no prompts ) . This is for newish ed ( 1 ) and stderr .
2008-11-08 17:36:35 +00:00
category: ! no - stderr - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
w
q
expected - stdout:
abc def
FOOBAR def
expected - stderr - pattern:
2005-05-23 15:02:04 +00:00
/^X*13\n16\necho FOOBAR def\nX*$/
2005-05-23 03:06:10 +00:00
- - -
name: history - ed - 2
description:
Correct command is edited when number given
2008-11-08 17:36:35 +00:00
category: ! no - stderr - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo line 1
echo line 2 is here
echo line 3
echo line 4
fc 2
s/is here/is changed/
w
q
expected - stdout:
line 1
line 2 is here
line 3
line 4
line 2 is changed
expected - stderr - pattern:
2005-05-23 15:02:04 +00:00
/^X*20\n23\necho line 2 is changed\nX*$/
2005-05-23 03:06:10 +00:00
- - -
name: history - ed - 3
description:
Newly created multi line commands show up as single command
in history .
2008-11-08 17:36:35 +00:00
category: ! no - stderr - ed
2011-03-28 21:58:06 +00:00
need - ctty: yes
2011-06-04 17:08:11 +00:00
need - pass: no
2005-05-23 03:06:10 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
echo abc def
fc echo
s/abc/FOOBAR/
$ a
echo a new line
.
w
q
fc - l
expected - stdout:
abc def
FOOBAR def
a new line
1 echo abc def
2 echo FOOBAR def
2015-07-05 17:04:26 +00:00
echo a new line
2005-05-23 03:06:10 +00:00
expected - stderr - pattern:
2005-05-23 15:02:04 +00:00
/^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
2005-05-23 03:06:10 +00:00
- - -
name: IFS - space - 1
description:
Simple test , default IFS
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
<1> <A> <B> <C> .
<2> < A B C > .
<3> <A> <B> <C> .
<4> <A> <B> <C> .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - colon - 1
description:
Simple test , IFS = :
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = :
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
<1> <A> <B> <C> .
<2> <A:B:C> .
<3> <A> <B> <C> .
<4> <A> <B> <C> .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - null - 1
description:
Simple test , IFS = ""
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = ""
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
<1> <A> <B> <C> .
<2> <ABC> .
<3> <A> <B> <C> .
<4> <A> <B> <C> .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - space - colon - 1
description:
Simple test , IFS = <white-space> :
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = "$IFS:"
set - -
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
showargs 5 : "$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
<1> .
<2> < > .
<3> .
<4> .
<5> <:> .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - space - colon - 2
description:
Simple test , IFS = <white-space> :
2009-06-11 12:42:21 +00:00
AT & T ksh fails this , POSIX says the test is correct .
2005-05-23 03:06:10 +00:00
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = "$IFS:"
set - -
showargs : "$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
<:> .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - space - colon - 4
description:
Simple test , IFS = <white-space> :
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = "$IFS:"
set - -
showargs "$@$@"
expected - stdout:
2015-01-25 15:23:43 +00:00
.
2005-05-23 03:06:10 +00:00
- - -
name: IFS - space - colon - 5
description:
Simple test , IFS = <white-space> :
2009-06-11 12:42:21 +00:00
Don ' t know what POSIX thinks of this . AT & T ksh does not do this .
2005-05-23 03:06:10 +00:00
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = "$IFS:"
set - -
showargs "${@:-}"
expected - stdout:
2015-01-25 15:23:43 +00:00
< > .
2005-05-23 03:06:10 +00:00
- - -
name: IFS - subst - 1
description:
Simple test , IFS = <white-space> :
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2005-05-23 03:06:10 +00:00
IFS = "$IFS:"
x = ":b: :"
echo - n '1:' ; for i in $ x ; do echo - n " [$i]" ; done ; echo
echo - n '2:' ; for i in : b:: ; do echo - n " [$i]" ; done ; echo
showargs 3 $ x
showargs 4 : b::
x = "a:b:"
echo - n '5:' ; for i in $ x ; do echo - n " [$i]" ; done ; echo
showargs 6 $ x
x = "a::c"
echo - n '7:' ; for i in $ x ; do echo - n " [$i]" ; done ; echo
showargs 8 $ x
echo - n '9:' ; for i in $ { FOO - `echo -n h:i` th:ere } ; do echo - n " [$i]" ; done ; echo
showargs 10 $ { FOO - `echo -n h:i` th:ere }
showargs 11 "${FOO-`echo -n h:i`th:ere}"
x = " A : B::D"
echo - n '12:' ; for i in $ x ; do echo - n " [$i]" ; done ; echo
showargs 13 $ x
expected - stdout:
1 : [] [ b ] []
2 : [ : b:: ]
2015-01-25 15:23:43 +00:00
<3> < > <b> < > .
<4> <:b::> .
2005-05-23 03:06:10 +00:00
5 : [ a ] [ b ]
2015-01-25 15:23:43 +00:00
<6> <a> <b> .
2005-05-23 03:06:10 +00:00
7 : [ a ] [] [ c ]
2015-01-25 15:23:43 +00:00
<8> <a> < > <c> .
2005-05-23 03:06:10 +00:00
9 : [ h ] [ ith ] [ ere ]
2015-01-25 15:23:43 +00:00
<10> <h> <ith> <ere> .
<11> <h:ith:ere> .
2005-05-23 03:06:10 +00:00
12 : [ A ] [ B ] [] [ D ]
2015-01-25 15:23:43 +00:00
<13> <A> <B> < > <D> .
2013-11-30 00:20:48 +00:00
- - -
name: IFS - subst - 2
description:
Check leading whitespace after trim does not make a field
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2013-11-30 00:20:48 +00:00
x = "X 1 2"
showargs 1 shift $ { x #X}
expected - stdout:
2015-01-25 15:23:43 +00:00
<1> <shift> <1> <2> .
2005-05-23 03:06:10 +00:00
- - -
2014-10-19 20:56:33 +00:00
name: IFS - subst - 3 - arr
2014-07-29 17:56:31 +00:00
description:
Check leading IFS non - whitespace after trim does make a field
2014-10-07 15:22:17 +00:00
but leading IFS whitespace does not , nor empty replacements
2014-07-29 17:56:31 +00:00
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2014-10-07 15:22:17 +00:00
showargs 0 $ { - + }
2014-07-29 17:56:31 +00:00
IFS = :
showargs 1 $ { - + : foo:bar }
2014-10-07 15:22:17 +00:00
IFS = ' '
showargs 2 $ { - + foo bar }
2014-07-29 17:56:31 +00:00
expected - stdout:
2015-01-25 15:23:43 +00:00
<0> .
<1> < > <foo> <bar> .
<2> <foo> <bar> .
2014-07-29 17:56:31 +00:00
- - -
2014-10-19 20:56:33 +00:00
name: IFS - subst - 3 - ass
description:
Check non - field semantics
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2014-10-19 20:56:33 +00:00
showargs 0 x = $ { - + }
IFS = :
showargs 1 x = $ { - + : foo:bar }
IFS = ' '
showargs 2 x = $ { - + foo bar }
expected - stdout:
2015-01-25 15:23:43 +00:00
<0> <x=> .
<1> <x=> <foo> <bar> .
<2> <x=> <foo> <bar> .
2014-10-19 20:56:33 +00:00
- - -
name: IFS - subst - 3 - lcl
description:
Check non - field semantics , smaller corner case ( LP #1381965)
stdin:
set - x
local regex = $ { 2 : - }
exit 1
expected - exit : e != 0
expected - stderr - pattern:
/regex=/
- - -
2014-10-03 17:32:12 +00:00
name: IFS - subst - 4 - 1
description:
reported by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a
IFS = ; q="$*" ; nq= $*
2015-01-25 15:23:43 +00:00
pfn "$*" $* "$q" "$nq"
2014-10-03 17:32:12 +00:00
[ "$q" = "$nq" ] && echo = true || echo = false
expected - stdout:
< spacedivdedargument
here >
<space>
<divded>
< argument
here >
< spacedivdedargument
here >
< spacedivdedargument
here >
= true
- - -
name: IFS - subst - 4 - 2
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a
IFS = ; q="$@" ; nq= $@
2015-01-25 15:23:43 +00:00
pfn "$*" $* "$q" "$nq"
2014-10-03 17:32:12 +00:00
[ "$q" = "$nq" ] && echo = true || echo = false
expected - stdout:
< spacedivdedargument
here >
<space>
<divded>
< argument
here >
< space divded argument
here >
< space divded argument
here >
= true
- - -
name: IFS - subst - 4 - 3
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a ; IFS =
qs = "$*"
nqs = $*
qk = "$@"
nqk = $@
2015-01-25 15:23:43 +00:00
print - nr - - '= qs ' ; pfn "$qs"
print - nr - - '=nqs ' ; pfn "$nqs"
print - nr - - '= qk ' ; pfn "$qk"
print - nr - - '=nqk ' ; pfn "$nqk"
print - nr - - '~ qs ' ; pfn "$*"
print - nr - - '~nqs ' ; pfn $*
print - nr - - '~ qk ' ; pfn "$@"
print - nr - - '~nqk ' ; pfn $@
2014-10-03 17:32:12 +00:00
expected - stdout:
= qs < spacedivdedargument
here >
= nqs < spacedivdedargument
here >
= qk < space divded argument
here >
= nqk < space divded argument
here >
~ qs < spacedivdedargument
here >
~ nqs <space>
<divded>
< argument
here >
~ qk <space>
<divded>
< argument
here >
~ nqk <space>
<divded>
< argument
here >
- - -
name: IFS - subst - 4 - 4
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a ; IFS =
qs = "$*"
2015-01-25 15:23:43 +00:00
print - nr - - '= qs ' ; pfn "$qs"
print - nr - - '~ qs ' ; pfn "$*"
2014-10-03 17:32:12 +00:00
nqs = $*
2015-01-25 15:23:43 +00:00
print - nr - - '=nqs ' ; pfn "$nqs"
print - nr - - '~nqs ' ; pfn $*
2014-10-03 17:32:12 +00:00
qk = "$@"
2015-01-25 15:23:43 +00:00
print - nr - - '= qk ' ; pfn "$qk"
print - nr - - '~ qk ' ; pfn "$@"
2014-10-03 17:32:12 +00:00
nqk = $@
2015-01-25 15:23:43 +00:00
print - nr - - '=nqk ' ; pfn "$nqk"
print - nr - - '~nqk ' ; pfn $@
2014-10-03 17:32:12 +00:00
expected - stdout:
= qs < spacedivdedargument
here >
~ qs < spacedivdedargument
here >
= nqs < spacedivdedargument
here >
~ nqs <space>
<divded>
< argument
here >
= qk < space divded argument
here >
~ qk <space>
<divded>
< argument
here >
= nqk < space divded argument
here >
~ nqk <space>
<divded>
< argument
here >
- - -
name: IFS - subst - 4 - 4 p
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a ; IFS =
unset v
qs = $ { v: - "$*" }
2015-01-25 15:23:43 +00:00
print - nr - - '= qs ' ; pfn "$qs"
print - nr - - '~ qs ' ; pfn $ { v: - "$*" }
2014-10-03 17:32:12 +00:00
nqs = $ { v: - $* }
2015-01-25 15:23:43 +00:00
print - nr - - '=nqs ' ; pfn "$nqs"
print - nr - - '~nqs ' ; pfn $ { v: - $* }
2014-10-03 17:32:12 +00:00
qk = $ { v: - "$@" }
2015-01-25 15:23:43 +00:00
print - nr - - '= qk ' ; pfn "$qk"
print - nr - - '~ qk ' ; pfn $ { v: - "$@" }
2014-10-03 17:32:12 +00:00
nqk = $ { v: - $@ }
2015-01-25 15:23:43 +00:00
print - nr - - '=nqk ' ; pfn "$nqk"
print - nr - - '~nqk ' ; pfn $ { v: - $@ }
2014-10-03 17:32:12 +00:00
expected - stdout:
= qs < spacedivdedargument
here >
~ qs < spacedivdedargument
here >
= nqs < spacedivdedargument
here >
~ nqs <space>
<divded>
< argument
here >
= qk < space divded argument
here >
~ qk <space>
<divded>
< argument
here >
= nqk < space divded argument
here >
~ nqk <space>
<divded>
< argument
here >
- - -
name: IFS - subst - 4 - 5
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a ; IFS = ,
qs = "$*"
2015-01-25 15:23:43 +00:00
print - nr - - '= qs ' ; pfn "$qs"
print - nr - - '~ qs ' ; pfn "$*"
2014-10-03 17:32:12 +00:00
nqs = $*
2015-01-25 15:23:43 +00:00
print - nr - - '=nqs ' ; pfn "$nqs"
print - nr - - '~nqs ' ; pfn $*
2014-10-03 17:32:12 +00:00
qk = "$@"
2015-01-25 15:23:43 +00:00
print - nr - - '= qk ' ; pfn "$qk"
print - nr - - '~ qk ' ; pfn "$@"
2014-10-03 17:32:12 +00:00
nqk = $@
2015-01-25 15:23:43 +00:00
print - nr - - '=nqk ' ; pfn "$nqk"
print - nr - - '~nqk ' ; pfn $@
2014-10-03 17:32:12 +00:00
expected - stdout:
= qs < space , divded , argument
here >
~ qs < space , divded , argument
here >
= nqs < space , divded , argument
here >
~ nqs <space>
<divded>
< argument
here >
= qk < space divded argument
here >
~ qk <space>
<divded>
< argument
here >
= nqk < space divded argument
here >
~ nqk <space>
<divded>
< argument
here >
- - -
name: IFS - subst - 4 - 5 p
description:
extended testsuite based on problem by mikeserv
stdin:
2015-01-25 15:23:43 +00:00
pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; }
2014-10-03 17:32:12 +00:00
a = ' space divded argument
here '
IFS = \ ; set - - $ a ; IFS = ,
unset v
qs = $ { v: - "$*" }
2015-01-25 15:23:43 +00:00
print - nr - - '= qs ' ; pfn "$qs"
print - nr - - '~ qs ' ; pfn $ { v: - "$*" }
2014-10-03 17:32:12 +00:00
nqs = $ { v: - $* }
2015-01-25 15:23:43 +00:00
print - nr - - '=nqs ' ; pfn "$nqs"
print - nr - - '~nqs ' ; pfn $ { v: - $* }
2014-10-03 17:32:12 +00:00
qk = $ { v: - "$@" }
2015-01-25 15:23:43 +00:00
print - nr - - '= qk ' ; pfn "$qk"
print - nr - - '~ qk ' ; pfn $ { v: - "$@" }
2014-10-03 17:32:12 +00:00
nqk = $ { v: - $@ }
2015-01-25 15:23:43 +00:00
print - nr - - '=nqk ' ; pfn "$nqk"
print - nr - - '~nqk ' ; pfn $ { v: - $@ }
2014-10-03 17:32:12 +00:00
expected - stdout:
= qs < space , divded , argument
here >
~ qs < space , divded , argument
here >
= nqs < space , divded , argument
here >
~ nqs <space>
<divded>
< argument
here >
= qk < space divded argument
here >
~ qk <space>
<divded>
< argument
here >
= nqk < space divded argument
here >
~ nqk <space>
<divded>
< argument
here >
- - -
name: IFS - subst - 5
description:
extended testsuite based on IFS - subst - 3
differs slightly from ksh93:
- omit trailing field in a3zna , a7ina ( unquoted $@ expansion )
- has extra middle fields in b5ins , b7ina ( IFS_NWS unquoted expansion )
differs slightly from bash:
- omit leading field in a5ins , a7ina ( IFS_NWS unquoted expansion )
differs slightly from zsh:
- differs in assignment , not expansion ; probably zsh bug
- has extra middle fields in b5ins , b7ina ( IFS_NWS unquoted expansion )
'emulate sh' zsh has extra fields in
- a5ins ( IFS_NWS unquoted $* )
- b5ins , matching mksh ’ s
2014-11-14 20:21:29 +00:00
! ! WARNING ! ! more to come: http: // austingroupbugs . net / view . php ? id = 888
2014-10-03 17:32:12 +00:00
stdin:
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - "" 2 "" ; pfb $* ; x = $* ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a1zns'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - "" 2 "" ; pfb "$*" ; x = "$*" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a2zqs'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - "" 2 "" ; pfb $@ ; x = $@ ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a3zna'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - "" 2 "" ; pfb "$@" ; x = "$@" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a4zqa'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - "" 2 "" ; pfb $* ; x = $* ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a5ins'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - "" 2 "" ; pfb "$*" ; x = "$*" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a6iqs'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - "" 2 "" ; pfb $@ ; x = $@ ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a7ina'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - "" 2 "" ; pfb "$@" ; x = "$@" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=a8iqa'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - A B "" "" C ; pfb $* ; x = $* ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b1zns'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - A B "" "" C ; pfb "$*" ; x = "$*" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b2zqs'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - A B "" "" C ; pfb $@ ; x = $@ ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b3zna'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = ; set - - A B "" "" C ; pfb "$@" ; x = "$@" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b4zqa'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - A B "" "" C ; pfb $* ; x = $* ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b5ins'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - A B "" "" C ; pfb "$*" ; x = "$*" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b6iqs'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - A B "" "" C ; pfb $@ ; x = $@ ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b7ina'
2015-01-25 15:23:43 +00:00
"$__progname" - c ' pfb ( ) { for s_arg in "$@" ; do print - r - - "[$s_arg]" ; done ; } ; pfn ( ) { for s_arg in "$@" ; do print - r - - "<$s_arg>" ; done ; } ;
IFS = , ; set - - A B "" "" C ; pfb "$@" ; x = "$@" ; pfn "$x" '
2014-10-03 17:32:12 +00:00
echo '=b8iqa'
expected - stdout:
[ 2 ]
<2>
= a1zns
[ 2 ]
<2>
= a2zqs
[ 2 ]
< 2 >
= a3zna
[]
[ 2 ]
[]
< 2 >
= a4zqa
[ 2 ]
<,2,>
= a5ins
[ , 2 , ]
<,2,>
= a6iqs
[ 2 ]
< 2 >
= a7ina
[]
[ 2 ]
[]
< 2 >
= a8iqa
[ A ]
[ B ]
[ C ]
<ABC>
= b1zns
[ ABC ]
<ABC>
= b2zqs
[ A ]
[ B ]
[ C ]
< A B C >
= b3zna
[ A ]
[ B ]
[]
[]
[ C ]
< A B C >
= b4zqa
[ A ]
[ B ]
[]
[]
[ C ]
<A,B,,,C>
= b5ins
[ A , B , , , C ]
<A,B,,,C>
= b6iqs
[ A ]
[ B ]
[]
[]
[ C ]
< A B C >
= b7ina
[ A ]
[ B ]
[]
[]
[ C ]
< A B C >
= b8iqa
- - -
2014-10-19 21:53:08 +00:00
name: IFS - subst - 6
description:
Regression wrt . vector expansion in trim
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2014-10-19 21:53:08 +00:00
IFS =
x = abc
set - - a b
showargs $ { x #$*}
expected - stdout:
<c> .
- - -
name: IFS - subst - 7
description:
ksh93 bug wrt . vector expansion in trim
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2014-10-19 21:53:08 +00:00
IFS = "*"
a = abcd
set - - '' c
showargs "$*" $ { a ##"$*"}
expected - stdout:
<*c> <abcd> .
- - -
2014-11-14 20:21:29 +00:00
name: IFS - subst - 8
description:
http: // austingroupbugs . net / view . php ? id = 221
stdin:
n ( ) { echo "$#" ; } ; n "${foo-$@}"
expected - stdout:
1
- - -
2015-02-19 22:26:50 +00:00
name: IFS - subst - 9
description:
Scalar context for $* / $@ in [ [ and case
stdin:
"$__progname" - c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
"$__progname" - c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
"$__progname" - c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
"$__progname" - c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
"$__progname" - c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
"$__progname" - c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
"$__progname" - c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
"$__progname" - c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
"$__progname" - c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
expected - stdout:
1 0
2 0
3 0
4 1
5 1
6 1
7 ok
8 ok
<9> <ab> < a b > .
- - -
2014-04-29 07:43:38 +00:00
name: IFS - arith - 1
description:
http: // austingroupbugs . net / view . php ? id = 832
stdin:
$ { ZSH_VERSION + false } || emulate sh
$ { BASH_VERSION + set - o posix }
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2014-04-29 07:43:38 +00:00
IFS = 0
showargs $( ( 1230456 ) )
expected - stdout:
<123> <456> .
- - -
2005-05-23 03:06:10 +00:00
name: integer - base - err - 1
description:
Can ' t have 0 base ( causes shell to exit )
expected - exit : e != 0
stdin:
typeset - i i
i = 3
i = 0 #4
echo $ i
expected - stderr - pattern:
/^.*:.*0#4.*\n$/
- - -
name: integer - base - err - 2
description:
Can 't have multiple bases in a ' constant ' ( causes shell to exit )
( ksh88 fails this test )
expected - exit : e != 0
stdin:
typeset - i i
i = 3
i = 2 #110#11
echo $ i
expected - stderr - pattern:
/^.*:.*2#110#11.*\n$/
- - -
name: integer - base - err - 3
description:
Syntax errors in expressions and effects on bases
( interactive so errors don ' t cause exits )
( ksh88 fails this test - shell exits , even with - i )
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
2007-01-12 10:18:22 +00:00
PS1 = # minimise prompt hassles
2005-05-23 03:06:10 +00:00
typeset - i4 a = 10
typeset - i a = 2 +
echo $ a
typeset - i4 a = 10
typeset - i2 a = 2 +
echo $ a
expected - stderr - pattern:
/^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
expected - stdout:
4 #22
4 #22
- - -
name: integer - base - err - 4
description:
Are invalid digits ( according to base ) errors ?
( ksh93 fails this test )
expected - exit : e != 0
stdin:
typeset - i i ;
i = 3 #4
expected - stderr - pattern:
/^([#\$] )?.*:.*3#4.*\n$/
- - -
name: integer - base - 1
description:
Missing number after base is treated as 0 .
stdin:
typeset - i i
i = 3
i = 2 #
echo $ i
expected - stdout:
0
- - -
name: integer - base - 2
description:
Check 'stickyness' of base in various situations
stdin:
typeset - i i = 8
echo $ i
echo - - - - - - - - - - A
typeset - i4 j = 8
echo $ j
echo - - - - - - - - - - B
typeset - i k = 8
typeset - i4 k = 8
echo $ k
echo - - - - - - - - - - C
typeset - i4 l
l = 3 #10
echo $ l
echo - - - - - - - - - - D
typeset - i m
m = 3 #10
echo $ m
echo - - - - - - - - - - E
n = 2 #11
typeset - i n
echo $ n
n = 10
echo $ n
echo - - - - - - - - - - F
typeset - i8 o = 12
typeset - i4 o
echo $ o
echo - - - - - - - - - - G
typeset - i p
let p = 8 #12
echo $ p
expected - stdout:
8
- - - - - - - - - - A
4 #20
- - - - - - - - - - B
4 #20
- - - - - - - - - - C
4 #3
- - - - - - - - - - D
3 #10
- - - - - - - - - - E
2 #11
2 #1010
- - - - - - - - - - F
4 #30
- - - - - - - - - - G
8 #12
- - -
name: integer - base - 3
description:
More base parsing ( hmm doesn ' t test much .. )
stdin:
typeset - i aa
aa = 1 + 12 #10+2
echo $ aa
typeset - i bb
bb = 1 + $ aa
echo $ bb
typeset - i bb
bb = $ aa
echo $ bb
typeset - i cc
cc = $ aa
echo $ cc
expected - stdout:
15
16
15
15
- - -
name: integer - base - 4
description:
Check that things not declared as integers are not made integers ,
also , check if base is not reset by - i with no arguments .
( ksh93 fails - prints 10 #20 - go figure)
stdin:
xx = 20
let xx = 10
typeset - i | grep '^xx='
typeset - i4 a = 10
typeset - i a = 20
echo $ a
expected - stdout:
4 #110
- - -
name: integer - base - 5
description:
More base stuff
stdin:
typeset - i4 a = 3 #10
echo $ a
echo - -
typeset - i j = 3
2006-08-28 17:42:55 +00:00
j = '~3'
2005-05-23 03:06:10 +00:00
echo $ j
echo - -
typeset - i k = 1
x [ k = k + 1 ] = 3
echo $ k
echo - -
typeset - i l
for l in 1 2 + 3 4 ; do echo $ l ; done
expected - stdout:
4 #3
- -
- 4
- -
2
- -
1
5
4
- - -
name: integer - base - 6
description:
Even more base stuff
( ksh93 fails this test - prints 0 )
stdin:
typeset - i7 i
i =
echo $ i
expected - stdout:
7 #0
- - -
name: integer - base - 7
description:
Check that non - integer parameters don ' t get bases assigned
stdin:
echo $( ( zz = 8 #100 ))
echo $ zz
expected - stdout:
64
64
- - -
2015-04-29 20:07:35 +00:00
name: integer - base - 8
description:
Check that base - 36 works ( full span )
stdin:
echo 1 : $( ( 36 #109AZ)).
typeset - i36 x = 1691675
echo 2 : $ x .
typeset - Uui36 x
echo 3 : $ x .
expected - stdout:
1 : 1691675 .
2 : 36 #109az.
3 : 36 #109AZ.
- - -
2012-04-07 11:19:53 +00:00
name: integer - base - check - flat
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
description:
2013-04-27 18:50:25 +00:00
Check behaviour does not match POSuX ( except if set - o posix ) ,
because a not type - safe scripting language has * no * business
interpreting the string "010" as octal numer eight ( dangerous ) .
2012-06-25 16:31:18 +00:00
stdin:
2013-04-27 18:50:25 +00:00
echo 1 "$(" $ __progname " -c 'echo :$((10))/$((010)),$((0x10)):')" .
echo 2 "$(" $ __progname " -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
echo 3 "$(" $ __progname " -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
2012-06-25 16:31:18 +00:00
expected - stdout:
2013-04-27 18:50:25 +00:00
1 : 10 / 10 , 16 : .
2 : 10 / 8 , 16 : .
3 : 10 / 10 , 16 : .
2012-06-25 16:31:18 +00:00
- - -
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
name: integer - base - check - numeric - from
description:
2014-12-15 23:18:47 +00:00
Check behaviour for base one to 36 , and that 37 degrades to 10
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
stdin:
echo 1 : $( ( 1 #1))0.
i = 1
2014-12-15 23:18:47 +00:00
while ( ( + + i <= 37 ) ) ; do
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
eval 'echo ' $ i ':$((' $ i '#10)).'
done
echo 37 : $( $ __progname - c 'echo $((37#10))' ) . $? :
expected - stdout:
1 : 490 .
2 : 2 .
3 : 3 .
4 : 4 .
5 : 5 .
6 : 6 .
7 : 7 .
8 : 8 .
9 : 9 .
10 : 10 .
11 : 11 .
12 : 12 .
13 : 13 .
14 : 14 .
15 : 15 .
16 : 16 .
17 : 17 .
18 : 18 .
19 : 19 .
20 : 20 .
21 : 21 .
22 : 22 .
23 : 23 .
24 : 24 .
25 : 25 .
26 : 26 .
27 : 27 .
28 : 28 .
29 : 29 .
30 : 30 .
31 : 31 .
32 : 32 .
33 : 33 .
34 : 34 .
35 : 35 .
36 : 36 .
2014-12-15 23:18:47 +00:00
37 : 10 .
37 : 10.0 :
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
- - -
name: integer - base - check - numeric - to
description:
2014-12-15 23:18:47 +00:00
Check behaviour for base one to 36 , and that 37 degrades to 10
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
stdin:
i = 0
while ( ( + + i <= 37 ) ) ; do
typeset - Uui $ i x = 0x40
eval "typeset -i10 y=$x"
print $ i: $ x . $ y .
done
expected - stdout:
1 : 1 #@.64.
2 : 2 #1000000.64.
3 : 3 #2101.64.
4 : 4 #1000.64.
5 : 5 #224.64.
6 : 6 #144.64.
7 : 7 #121.64.
8 : 8 #100.64.
9 : 9 #71.64.
10 : 64.64 .
11 : 11 #59.64.
12 : 12 #54.64.
13 : 13 #4C.64.
14 : 14 #48.64.
15 : 15 #44.64.
16 : 16 #40.64.
17 : 17 #3D.64.
18 : 18 #3A.64.
19 : 19 #37.64.
20 : 20 #34.64.
21 : 21 #31.64.
22 : 22 #2K.64.
23 : 23 #2I.64.
24 : 24 #2G.64.
25 : 25 #2E.64.
26 : 26 #2C.64.
27 : 27 #2A.64.
28 : 28 #28.64.
29 : 29 #26.64.
30 : 30 #24.64.
31 : 31 #22.64.
32 : 32 #20.64.
33 : 33 #1V.64.
34 : 34 #1U.64.
35 : 35 #1T.64.
36 : 36 #1S.64.
2014-12-15 23:18:47 +00:00
37 : 64.64 .
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
- - -
name: integer - arithmetic - span
description:
Check wraparound and size that is defined in mksh
2012-06-28 20:17:39 +00:00
category: int : 32
add tests for
• integer base flat (10, 010, 0x10)
‣ posix, right variants (heh, just like timezones)
⇒ both enabled, which means one test always fails right now,
until the code changes are in…
☹ mksh R21 and up, AT&T ksh93, posh, GNU bash, busybox sh, dash
all use the posux variant
☺ mksh R20b and below, pdksh, zsh, python, perl, php all do it right
‣ posix is stupid to use C (strongly typed, compiled) semantics
for an untyped _scripting_ language
• integer bases 1 (mksh specific), 2 to 36, and that 37 errors out
‣ both directions
• integer arithmetic, signed and unsigned, wraparound and value span
2011-12-09 20:40:02 +00:00
stdin:
echo s: $( ( 2147483647 + 1 ) ) . $( ( ( 2147483647 * 2 ) + 1 ) ) . $( ( ( 2147483647 * 2 ) + 2 ) ) .
echo u: $( ( #2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
expected - stdout:
s: - 2147483648 . - 1.0 .
u:2147483648 .4294967295 .0 .
- - -
2012-06-28 20:17:39 +00:00
name: integer - arithmetic - span - 64
description:
Check wraparound and size that is defined in mksh
category: int : 64
stdin:
echo s: $( ( 9223372036854775807 + 1 ) ) . $( ( ( 9223372036854775807 * 2 ) + 1 ) ) . $( ( ( 9223372036854775807 * 2 ) + 2 ) ) .
echo u: $( ( #9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
expected - stdout:
s: - 9223372036854775808 . - 1.0 .
u:9223372036854775808 .18446744073709551615 .0 .
- - -
2013-04-26 19:40:45 +00:00
name: integer - size - FAIL - to - detect
description:
Notify the user that their ints are not 32 or 64 bit
category: int : u
stdin:
:
- - -
2005-05-23 03:06:10 +00:00
name: lineno - stdin
description:
See if $ LINENO is updated and can be modified .
stdin:
echo A $ LINENO
echo B $ LINENO
LINENO = 20
echo C $ LINENO
expected - stdout:
A 1
B 2
C 20
- - -
name: lineno - inc
description:
See if $ LINENO is set for . ' d files .
file - setup: file 644 "dotfile"
echo dot A $ LINENO
echo dot B $ LINENO
LINENO = 20
echo dot C $ LINENO
stdin:
echo A $ LINENO
echo B $ LINENO
. . / dotfile
expected - stdout:
A 1
B 2
dot A 1
dot B 2
dot C 20
- - -
name: lineno - func
description:
See if $ LINENO is set for commands in a function .
stdin:
echo A $ LINENO
echo B $ LINENO
bar ( ) {
echo func A $ LINENO
echo func B $ LINENO
}
bar
echo C $ LINENO
expected - stdout:
A 1
B 2
func A 4
func B 5
C 8
- - -
name: lineno - unset
description:
See if unsetting LINENO makes it non - magic .
file - setup: file 644 "dotfile"
echo dot A $ LINENO
echo dot B $ LINENO
stdin:
unset LINENO
echo A $ LINENO
echo B $ LINENO
bar ( ) {
echo func A $ LINENO
echo func B $ LINENO
}
bar
. . / dotfile
echo C $ LINENO
expected - stdout:
A
B
func A
func B
dot A
dot B
C
- - -
name: lineno - unset - use
description:
See if unsetting LINENO makes it non - magic even
when it is re - used .
file - setup: file 644 "dotfile"
echo dot A $ LINENO
echo dot B $ LINENO
stdin:
unset LINENO
LINENO = 3
echo A $ LINENO
echo B $ LINENO
bar ( ) {
echo func A $ LINENO
echo func B $ LINENO
}
bar
. . / dotfile
echo C $ LINENO
expected - stdout:
A 3
B 3
func A 3
func B 3
dot A 3
dot B 3
C 3
- - -
2010-05-22 12:49:16 +00:00
name: lineno - trap
description:
Check if LINENO is tracked in traps
stdin:
fail ( ) {
echo "line <$1>"
exit 1
}
trap 'fail $LINENO' INT ERR
false
expected - stdout:
line <6>
expected - exit : 1
- - -
2011-01-30 01:36:00 +00:00
name: unknown - trap
description:
Ensure unknown traps are not a syntax error
stdin:
(
trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
echo = 1
trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
echo = $?
2012-01-05 11:52:48 +00:00
) 2 > & 1 | sed "s ^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*] PROG "
2011-01-30 01:36:00 +00:00
expected - stdout:
PROG: trap: bad signal 'UNKNOWNSIGNAL'
foo
= 1
PROG: trap: bad signal 'UNKNOWNSIGNAL'
PROG: trap: bad signal '999999'
PROG: trap: bad signal 'FNORD'
2015-04-29 20:44:37 +00:00
= 1
2011-01-30 01:36:00 +00:00
trap 2 executed
- - -
2005-05-23 03:06:10 +00:00
name: read - IFS - 1
description:
Simple test , default IFS
stdin:
echo "A B " > IN
unset x y z
read x y z < IN
echo 1 : "x[$x] y[$y] z[$z]"
echo 1 a: $ { z - z not set }
read x < IN
echo 2 : "x[$x]"
expected - stdout:
1 : x [ A ] y [ B ] z []
1 a:
2 : x [ A B ]
- - -
2015-04-11 21:18:47 +00:00
name: read - IFS - 2
description:
Complex tests , IFS either colon ( IFS - NWS ) or backslash ( tricky )
stdin:
n = 0
showargs ( ) { print - nr "$1" ; shift ; for s_arg in "$@" ; do print - nr - - " [$s_arg]" ; done ; print ; }
( IFS = \ \ a = \ <\\\> ; showargs 3 $ a )
( IFS = : b = \ <:\> ; showargs 4 $ b )
print - r '<\>' | ( IFS = \ \ read f g ; showargs 5 "$f" "$g" )
print - r '<\\>' | ( IFS = \ \ read f g ; showargs 6 "$f" "$g" )
print '<\\\n>' | ( IFS = \ \ read f g ; showargs 7 "$f" "$g" )
print - r '<\>' | ( IFS = \ \ read f ; showargs 8 "$f" )
print - r '<\\>' | ( IFS = \ \ read f ; showargs 9 "$f" )
print '<\\\n>' | ( IFS = \ \ read f ; showargs 10 "$f" )
print - r '<\>' | ( IFS = \ \ read - r f g ; showargs 11 "$f" "$g" )
print - r '<\\>' | ( IFS = \ \ read - r f g ; showargs 12 "$f" "$g" )
print '<\\\n>' | ( IFS = \ \ read - r f g ; showargs 13 "$f" "$g" )
print - r '<\>' | ( IFS = \ \ read - r f ; showargs 14 "$f" )
print - r '<\\>' | ( IFS = \ \ read - r f ; showargs 15 "$f" )
print '<\\\n>' | ( IFS = \ \ read - r f ; showargs 16 "$f" )
print - r '<:>' | ( IFS = : read f g ; showargs 17 "$f" "$g" )
print - r '<::>' | ( IFS = : read f g ; showargs 18 "$f" "$g" )
print '<:\n>' | ( IFS = : read f g ; showargs 19 "$f" "$g" )
print - r '<:>' | ( IFS = : read f ; showargs 20 "$f" )
print - r '<::>' | ( IFS = : read f ; showargs 21 "$f" )
print '<:\n>' | ( IFS = : read f ; showargs 22 "$f" )
print - r '<:>' | ( IFS = : read - r f g ; showargs 23 "$f" "$g" )
print - r '<::>' | ( IFS = : read - r f g ; showargs 24 "$f" "$g" )
print '<:\n>' | ( IFS = : read - r f g ; showargs 25 "$f" "$g" )
print - r '<:>' | ( IFS = : read - r f ; showargs 26 "$f" )
print - r '<::>' | ( IFS = : read - r f ; showargs 27 "$f" )
print '<:\n>' | ( IFS = : read - r f ; showargs 28 "$f" )
expected - stdout:
3 [ < ] [ > ]
4 [ < ] [ > ]
5 [ < ] [ > ]
6 [ < ] [ > ]
7 [ < > ] []
8 [ < > ]
9 [ <\> ]
10 [ < > ]
11 [ < ] [ > ]
12 [ < ] [ \ > ]
13 [ < ] []
14 [ <\> ]
15 [ <\\> ]
16 [ < ]
17 [ < ] [ > ]
18 [ < ] [ : > ]
19 [ < ] []
20 [ <:> ]
21 [ <::> ]
22 [ < ]
23 [ < ] [ > ]
24 [ < ] [ : > ]
25 [ < ] []
26 [ <:> ]
27 [ <::> ]
28 [ < ]
- - -
2005-05-23 03:06:10 +00:00
name: read - ksh - 1
description:
If no var specified , REPLY is used
stdin:
echo "abc" > IN
read < IN
echo "[$REPLY]" ;
expected - stdout:
[ abc ]
- - -
2011-01-22 20:33:14 +00:00
name: read - regress - 1
description:
Check a regression of read
file - setup: file 644 "foo"
foo bar
baz
blah
stdin:
while read a b c ; do
read d
break
done < foo
echo "<$a|$b|$c><$d>"
expected - stdout:
<foo|bar|> <baz>
- - -
2011-01-21 22:00:17 +00:00
name: read - delim - 1
description:
Check read with delimiters
stdin:
emit ( ) {
2012-03-20 16:48:12 +00:00
print - n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
2011-01-21 22:00:17 +00:00
}
emit | while IFS = read - d "" foo ; do print - r - - "<$foo>" ; done
emit | while read - d "" foo ; do print - r - - "<$foo>" ; done
emit | while read - d "eh?" foo ; do print - r - - "<$foo>" ; done
expected - stdout:
< foo bar baz
blah >
< blub blech
myok meck >
< foo bar baz
blah >
< blub blech
myok meck >
< foo bar baz
blah blub bl >
< ch
myok m >
- - -
2011-05-29 02:18:57 +00:00
name: read - ext - 1
description:
Check read with number of bytes specified , and - A
stdin:
print 'foo\nbar' > x1
print - n x > x2
print 'foo\\ bar baz' > x3
x1a = u ; read x1a < x1
x1b = u ; read - N - 1 x1b < x1
x2a = u ; read x2a < x2 ; r2a = $?
x2b = u ; read - N2 x2c < x2 ; r2b = $?
x2c = u ; read - n2 x2c < x2 ; r2c = $?
x3a = u ; read - A x3a < x3
print - r "x1a=<$x1a>"
print - r "x1b=<$x1b>"
print - r "x2a=$r2a<$x2a>"
print - r "x2b=$r2b<$x2b>"
print - r "x2c=$r2c<$x2c>"
print - r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
expected - stdout:
x1a = <foo>
x1b = < foo
bar >
x2a = 1 <x>
x2b = 1 <u>
x2c = 0 <x>
x3a = < foo bar | baz | >
- - -
2005-05-23 03:06:10 +00:00
name: regression - 1
description:
Lex array code had problems with this .
stdin:
echo foo [
n = bar
echo "hi[ $n ]=1"
expected - stdout:
foo [
hi [ bar ] = 1
- - -
name: regression - 2
description:
When PATH is set before running a command , the new path is
not used in doing the path search
$ echo echo hi > /tmp/ q ; chmod a + rx /tmp/ q
$ PATH = / tmp q
q: not found
$
in comexec ( ) the two lines
while ( * vp != NULL )
( void ) typeset ( * vp + + , xxx , 0 ) ;
need to be moved out of the switch to before findcom ( ) is
called - I don ' t know what this will break .
stdin:
2015-07-09 20:11:45 +00:00
: "${PWD:-`pwd 2> /dev/null`}"
2015-12-11 16:55:55 +00:00
: "${PWD:?" PWD not set - cannot do test "}"
2005-05-23 03:06:10 +00:00
mkdir Y
cat > Y / xxxscript << EOF
#!/bin/sh
# Need to restore path so echo can be found (some shells don't have
# it as a built-in)
PATH = \ $ OLDPATH
echo hi
exit 0
EOF
chmod a + rx Y / xxxscript
export OLDPATH = "$PATH"
PATH = $ PWD / Y xxxscript
exit $?
expected - stdout:
hi
- - -
name: regression - 6
description:
Parsing of $( .. ) expressions is non - optimal . It is
impossible to have any parentheses inside the expression .
I . e . ,
$ ksh - c 'echo $(echo \( )'
no closing quote
$ ksh - c 'echo $(echo "(" )'
no closing quote
$
The solution is to hack the parsing clode in lex . c , the
question is how to hack it: should any parentheses be
escaped by a backslash , or should recursive parsing be done
( so quotes could also be used to hide hem ) . The former is
easier , the later better ...
stdin:
2012-06-28 20:05:11 +00:00
echo $ ( echo \ ( )
echo $ ( echo "(" )
2005-05-23 03:06:10 +00:00
expected - stdout:
(
2012-06-28 20:05:11 +00:00
(
2005-05-23 03:06:10 +00:00
- - -
name: regression - 9
description:
Continue in a for loop does not work right:
for i in a b c ; do
if [ $ i = b ] ; then
continue
fi
echo $ i
done
Prints a forever ...
stdin:
first = yes
for i in a b c ; do
if [ $ i = b ] ; then
if [ $ first = no ] ; then
echo 'continue in for loop broken'
break # hope break isn't broken too :-)
fi
first = no
continue
fi
done
echo bye
expected - stdout:
bye
- - -
2010-01-28 15:18:51 +00:00
name: regression - 10
description:
The following:
set - - `false`
echo $?
should print 0 according to POSIX ( dash , bash , ksh93 , posh )
but not 0 according to the getopt ( 1 ) manual page , ksh88 , and
Bourne sh ( such as /bin/s h on Solaris ) .
2013-05-02 20:21:45 +00:00
We honour POSIX except when - o sh is set .
2012-06-25 16:17:54 +00:00
category: shell:legacy - no
2010-01-28 15:18:51 +00:00
stdin:
showf ( ) {
[ [ - o posix ] ] ; FPOSIX = $( ( 1 - $? ) )
[ [ - o sh ] ] ; FSH = $( ( 1 - $? ) )
echo - n "FPOSIX=$FPOSIX FSH=$FSH "
}
set + o posix + o sh
showf
set - - `false`
echo rv = $?
set - o sh
showf
set - - `false`
echo rv = $?
set - o posix
showf
set - - `false`
echo rv = $?
2013-05-02 20:21:45 +00:00
set - o posix - o sh
showf
set - - `false`
echo rv = $?
2010-01-28 15:18:51 +00:00
expected - stdout:
FPOSIX = 0 FSH = 0 rv = 0
FPOSIX = 0 FSH = 1 rv = 1
FPOSIX = 1 FSH = 0 rv = 0
2013-05-02 20:21:45 +00:00
FPOSIX = 1 FSH = 1 rv = 0
2010-01-28 15:18:51 +00:00
- - -
2012-06-25 16:17:54 +00:00
name: regression - 10 - legacy
description:
The following:
set - - `false`
echo $?
should print 0 according to POSIX ( dash , bash , ksh93 , posh )
but not 0 according to the getopt ( 1 ) manual page , ksh88 , and
Bourne sh ( such as /bin/s h on Solaris ) .
category: shell:legacy - yes
stdin:
showf ( ) {
[ [ - o posix ] ] ; FPOSIX = $( ( 1 - $? ) )
[ [ - o sh ] ] ; FSH = $( ( 1 - $? ) )
echo - n "FPOSIX=$FPOSIX FSH=$FSH "
}
set + o posix + o sh
showf
set - - `false`
echo rv = $?
set - o sh
showf
set - - `false`
echo rv = $?
set - o posix
showf
set - - `false`
echo rv = $?
2013-05-02 20:21:45 +00:00
set - o posix - o sh
showf
set - - `false`
echo rv = $?
2012-06-25 16:17:54 +00:00
expected - stdout:
2012-06-25 16:34:58 +00:00
FPOSIX = 0 FSH = 0 rv = 1
FPOSIX = 0 FSH = 1 rv = 1
2013-05-02 20:21:45 +00:00
FPOSIX = 1 FSH = 0 rv = 0
FPOSIX = 1 FSH = 1 rv = 0
2012-06-25 16:17:54 +00:00
- - -
2005-05-23 03:06:10 +00:00
name: regression - 11
description:
The following:
x = /foo/ bar / blah
echo $ { x ##*/}
should echo blah but on some machines echos /foo/ bar / blah .
stdin:
x = /foo/ bar / blah
echo $ { x ##*/}
expected - stdout:
blah
- - -
name: regression - 12
description:
Both of the following echos produce the same output under sh / ksh . att:
#!/bin/sh
x = "foo bar"
echo "`echo \"$x\"`"
echo "`echo " $ x "`"
pdksh produces different output for the former ( foo instead of foo \ tbar )
stdin:
x = "foo bar"
echo "`echo \"$x\"`"
echo "`echo " $ x "`"
expected - stdout:
foo bar
foo bar
- - -
name: regression - 13
description:
The following command hangs forever:
$ ( : ; cat /etc/ termcap ) | sleep 2
This is because the shell forks a shell to run the ( .. ) command
and this shell has the pipe open . When the sleep dies , the cat
doesn 't get a SIGPIPE ' cause a process ( ie , the second shell )
still has the pipe open .
NOTE: this test provokes a bizarre bug in ksh93 ( shell starts reading
commands from /etc/ termcap .. )
time - limit: 10
stdin:
echo A line of text that will be duplicated quite a number of times . > t1
cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
cat t1 t1 t1 t1 > t2
2013-02-10 19:04:00 +00:00
( : ; cat t2 2 > /dev/ null ) | sleep 1
2005-05-23 03:06:10 +00:00
- - -
name: regression - 14
description:
The command
$ ( foobar ) 2 > /dev/ null
generates no output under /bin/s h , but pdksh produces the error
foobar: not found
Also , the command
$ foobar 2 > /dev/ null
2009-06-11 12:42:21 +00:00
generates an error under /bin/s h and pdksh , but AT & T ksh88 produces
2005-05-23 03:06:10 +00:00
no error ( redirected to /dev/ null ) .
stdin:
( you /should/ not /see/ this /error/ 1 ) 2 > /dev/ null
you /should/ not /see/ this /error/ 2 2 > /dev/ null
true
- - -
name: regression - 15
description:
The command
$ whence foobar
generates a blank line under pdksh and sets the exit status to 0 .
2009-06-11 12:42:21 +00:00
AT & T ksh88 generates no output and sets the exit status to 1 . Also ,
2005-05-23 03:06:10 +00:00
the command
$ whence foobar cat
2009-06-11 12:42:21 +00:00
generates no output under AT & T ksh88 ( pdksh generates a blank line
2005-05-23 03:06:10 +00:00
and /bin/c at ) .
stdin:
whence does /not/ exist > /dev/ null
echo 1 : $?
echo 2 : $ ( whence does /not/ exist | wc - l )
echo 3 : $ ( whence does /not/ exist cat | wc - l )
expected - stdout:
1 : 1
2 : 0
3 : 0
- - -
name: regression - 16
description:
$ { var %% expr } seems to be broken in many places . On the mips
the commands
$ read line < /etc/ passwd
$ echo $ line
root:0:1: ...
$ echo $ { line %% : * }
root
$ echo $ line
root
$
change the value of line . On sun4s & pas , the echo $ { line %% : * } doesn ' t
work . Haven ' t checked elsewhere ...
script:
read x
y = $ x
echo $ { x %% : * }
echo $ x
stdin:
root:asdjhasdasjhs:0:1:Root: /:/ bin / sh
expected - stdout:
root
root:asdjhasdasjhs:0:1:Root: /:/ bin / sh
- - -
name: regression - 17
description:
The command
. /foo/ bar
2009-06-11 12:42:21 +00:00
should set the exit status to non - zero ( sh and AT & T ksh88 do ) .
2005-05-23 03:06:10 +00:00
XXX doting a non existent file is a fatal error for a script
stdin:
. does /not/ exist
expected - exit : e != 0
expected - stderr - pattern: /.?/
- - -
name: regression - 19
description:
Both of the following echos should produce the same thing , but don ' t:
$ x = foo / bar
$ echo $ { x % / * }
foo
$ echo "${x%/*}"
foo / bar
stdin:
x = foo / bar
echo "${x%/*}"
expected - stdout:
foo
- - -
name: regression - 21
description:
backslash does not work as expected in case labels:
$ x = '-x'
$ case $ x in
- \ ? ) echo hi
esac
hi
$ x = '-?'
$ case $ x in
- \ \ ? ) echo hi
esac
hi
$
stdin:
case - x in
- \ ? ) echo fail
esac
- - -
name: regression - 22
description:
Quoting backquotes inside backquotes doesn ' t work:
$ echo `echo hi \`echo there\` folks`
2009-06-11 12:42:21 +00:00
asks for more info . sh and AT & T ksh88 both echo
2005-05-23 03:06:10 +00:00
hi there folks
stdin:
echo `echo hi \`echo there\` folks`
expected - stdout:
hi there folks
- - -
name: regression - 23
description:
) ) is not treated ` correctly ' :
$ ( echo hi ; ( echo there ; echo folks ) )
missing ( (
$
instead of ( as sh and ksh . att )
$ ( echo hi ; ( echo there ; echo folks ) )
hi
there
folks
$
stdin:
( : ; ( : ; echo hi ) )
expected - stdout:
hi
- - -
name: regression - 25
description:
Check reading stdin in a while loop . The read should only read
a single line , not a whole stdio buffer ; the cat should get
the rest .
stdin:
( echo a ; echo b ) | while read x ; do
echo $ x
cat > /dev/ null
done
expected - stdout:
a
- - -
name: regression - 26
description:
Check reading stdin in a while loop . The read should read both
lines , not just the first .
script:
a =
while [ "$a" != xxx ] ; do
last = $ x
read x
cat /dev/ null | sed 's/x/y/'
a = x $ a
done
echo $ last
stdin:
a
b
expected - stdout:
b
- - -
name: regression - 27
description:
The command
. /does/ not / exist
should cause a script to exit .
stdin:
. does /not/ exist
echo hi
expected - exit : e != 0
expected - stderr - pattern: /does\/not\/exist/
- - -
name: regression - 28
description:
variable assignements not detected well
stdin:
a . x = 1 echo hi
expected - exit : e != 0
expected - stderr - pattern: /a\.x=1/
- - -
name: regression - 29
description:
2009-06-11 12:42:21 +00:00
alias expansion different from AT & T ksh88
2005-05-23 03:06:10 +00:00
stdin:
alias a = 'for ' b = 'i in'
a b hi ; do echo $ i ; done
expected - stdout:
hi
- - -
name: regression - 30
description:
strange characters allowed inside $ { ... }
stdin:
echo $ { a { b } }
expected - exit : e != 0
expected - stderr - pattern: /.?/
- - -
name: regression - 31
description:
Does read handle partial lines correctly
script:
a = ret =
while [ "$a" != xxx ] ; do
read x y z
ret = $?
a = x $ a
done
echo "[$x]"
echo $ ret
stdin: !
a A aA
b B Bb
c
expected - stdout:
[ c ]
1
- - -
name: regression - 32
description:
Does read set variables to null at eof ?
script:
a =
while [ "$a" != xxx ] ; do
read x y z
a = x $ a
done
2005-07-07 23:27:52 +00:00
echo 1 : $ { x - x not set } $ { y - y not set } $ { z - z not set }
2005-05-23 03:06:10 +00:00
echo 2 : $ { x: + x not null } $ { y: + y not null } $ { z: + z not null }
stdin:
a A Aa
b B Bb
expected - stdout:
1 :
2 :
- - -
name: regression - 33
description:
Does umask print a leading 0 when umask is 3 digits ?
stdin:
2011-02-27 19:41:17 +00:00
# on MiNT, the first umask call seems to fail
umask 022
# now, the test proper
umask 222
2005-05-23 03:06:10 +00:00
umask
expected - stdout:
2011-02-27 19:41:17 +00:00
0222
2005-05-23 03:06:10 +00:00
- - -
name: regression - 35
description:
Tempory files used for here - docs in functions get trashed after
the function is parsed ( before it is executed )
stdin:
f1 ( ) {
cat << - EOF
F1
EOF
f2 ( ) {
cat << - EOF
F2
EOF
}
}
f1
f2
unset - f f1
f2
expected - stdout:
F1
F2
F2
- - -
name: regression - 36
description:
Command substitution breaks reading in while loop
( test from <sjg@void.zen.oz.au> )
stdin:
2005-07-07 23:27:52 +00:00
( echo abcdef ; echo ; echo 123 ) |
2005-05-23 03:06:10 +00:00
while read line
do
# the following line breaks it
c = `echo $line | wc -c`
echo $ c
done
expected - stdout:
7
1
4
- - -
name: regression - 37
description:
Machines with broken times ( ) ( reported by <sjg@void.zen.oz.au> )
time does not report correct real time
stdin:
time sleep 1
expected - stderr - pattern: ! /^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
- - -
name: regression - 38
description:
set - e doesn ' t ignore exit codes for if /while/ until /&&/ || / ! .
arguments: ! - e !
stdin:
if false ; then echo hi ; fi
false || true
false && true
2005-07-07 23:27:52 +00:00
while false ; do echo hi ; done
2005-05-23 03:06:10 +00:00
echo ok
expected - stdout:
ok
- - -
name: regression - 39
description:
2013-07-21 18:36:03 +00:00
Only posh and oksh ( 2013 - 07 ) say “ hi ” below ; FreeBSD sh ,
GNU bash in POSIX mode , dash , ksh93 , mksh don ’ t . All of
them exit 0 . The POSIX behaviour is needed by BSD make .
2005-05-23 03:06:10 +00:00
stdin:
2013-07-21 18:36:03 +00:00
set - e
slightly optimised and, more importantly, much more consistent (use only
one set of CTRL, UNCTRL, and new ISCTRL macros) C0 and DEL handling; the
optimisation only works for 7-bit ASCII, so those places 8-bit must pass
intact have an added check
also, while here, remove an editor oops (‘;’), oksh rcsid sync (they did
accept I was right wrt. set -e), int → bool, and code merge/cleanup
2013-09-24 20:19:45 +00:00
echo `false; echo hi` $( < this - file - does - not - exist )
2013-07-21 18:36:03 +00:00
echo $?
2005-05-23 03:06:10 +00:00
expected - stdout:
2006-08-02 12:38:45 +00:00
2013-07-21 18:36:03 +00:00
0
slightly optimised and, more importantly, much more consistent (use only
one set of CTRL, UNCTRL, and new ISCTRL macros) C0 and DEL handling; the
optimisation only works for 7-bit ASCII, so those places 8-bit must pass
intact have an added check
also, while here, remove an editor oops (‘;’), oksh rcsid sync (they did
accept I was right wrt. set -e), int → bool, and code merge/cleanup
2013-09-24 20:19:45 +00:00
expected - stderr - pattern: /this-file-does-not-exist/
2005-05-23 03:06:10 +00:00
- - -
name: regression - 40
description:
This used to cause a core dump
env - setup: ! RANDOM = 12 !
stdin:
echo hi
expected - stdout:
hi
- - -
name: regression - 41
description:
foo should be set to bar ( should not be empty )
stdin:
foo = `
echo bar `
echo "($foo)"
expected - stdout:
( bar )
- - -
name: regression - 42
description:
Can ' t use command line assignments to assign readonly parameters .
stdin:
2012-03-31 18:18:41 +00:00
print '#!' "$__progname" '\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval ' \ '' print - r - - "$RANDOM=$'\''" $ RANDOM " ' \ ' \ " \ ' \ ; \
2015-07-10 19:36:38 +00:00
done > env ; chmod + x env ; PATH = . $ PATHSEP $ PATH
2005-05-23 03:06:10 +00:00
foo = bar
readonly foo
foo = stuff env | grep '^foo'
expected - exit : e != 0
expected - stderr - pattern:
2011-12-16 20:03:28 +00:00
/read-only/
2005-05-23 03:06:10 +00:00
- - -
name: regression - 43
description:
Can subshells be prefixed by redirections ( historical shells allow
this )
stdin:
< /dev/ null ( sed 's/^/X/' )
- - -
name: regression - 45
description:
2007-01-12 10:18:22 +00:00
Parameter assignments with [] recognised correctly
2005-05-23 03:06:10 +00:00
stdin:
FOO = * [ 12 ]
BAR = abc [
MORE = [ abc ]
JUNK = a [ bc
echo "<$FOO>"
echo "<$BAR>"
echo "<$MORE>"
echo "<$JUNK>"
expected - stdout:
<*[12]>
<abc[>
<[abc]>
<a[bc>
- - -
name: regression - 46
description:
Check that alias expansion works in command substitutions and
at the end of file .
stdin:
alias x = 'echo hi'
FOO = "`x` "
echo "[$FOO]"
x
expected - stdout:
[ hi ]
hi
- - -
name: regression - 47
description:
Check that aliases are fully read .
stdin:
alias x = ' echo hi ;
echo there '
x
echo done
expected - stdout:
hi
there
done
- - -
name: regression - 48
description:
Check that ( here doc ) temp files are not left behind after an exec .
stdin:
mkdir foo || exit 1
2008-04-01 16:01:45 +00:00
TMPDIR = $ PWD / foo "$__progname" << - 'EOF'
2005-05-23 03:06:10 +00:00
x ( ) {
sed 's/^/X /' << E_O_F
hi
there
folks
E_O_F
echo "done ($?)"
}
echo = echo ; [ - x /bin/ echo ] && echo = /bin/ echo
exec $ echo subtest - 1 hi
EOF
echo subtest - 1 foo / *
2008-04-01 16:01:45 +00:00
TMPDIR = $ PWD / foo "$__progname" << - 'EOF'
2005-05-23 03:06:10 +00:00
echo = echo ; [ - x /bin/ echo ] && echo = /bin/ echo
sed 's/^/X /' << E_O_F ; exec $ echo subtest - 2 hi
a
few
lines
E_O_F
EOF
echo subtest - 2 foo / *
expected - stdout:
subtest - 1 hi
subtest - 1 foo / *
X a
X few
X lines
subtest - 2 hi
subtest - 2 foo / *
- - -
name: regression - 49
description:
Check that unset params with attributes are reported by set , those
sans attributes are not .
stdin:
unset FOO BAR
echo X $ FOO
export BAR
typeset - i BLAH
set | grep FOO
set | grep BAR
set | grep BLAH
expected - stdout:
X
BAR
BLAH
- - -
name: regression - 50
description:
Check that aliases do not use continuation prompt after trailing
semi - colon .
2012-03-31 18:18:41 +00:00
file - setup: file 644 "envf"
2005-05-23 03:06:10 +00:00
PS1 = Y
PS2 = X
2012-03-31 18:18:41 +00:00
env - setup: ! ENV = . / envf !
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
alias foo = 'echo hi ; '
foo
foo echo there
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
hi
hi
there
expected - stderr: !
YYYY
- - -
name: regression - 51
description:
Check that set allows both + o and - o options on same command line .
stdin:
set a b c
set - o noglob + o allexport
echo A: $* , *
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
A: a b c , *
- - -
name: regression - 52
description:
2008-02-27 11:24:12 +00:00
Check that globbing works in pipelined commands
2012-03-31 18:18:41 +00:00
file - setup: file 644 "envf"
2005-05-23 03:06:10 +00:00
PS1 = P
file - setup: file 644 "abc"
stuff
2012-03-31 18:18:41 +00:00
env - setup: ! ENV = . / envf !
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
sed 's/^/X /' < ab *
echo mark 1
sed 's/^/X /' < ab * | sed 's/^/Y /'
echo mark 2
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
X stuff
mark 1
Y X stuff
mark 2
expected - stderr: !
PPPPP
- - -
name: regression - 53
description:
Check that getopts works in functions
stdin:
bfunc ( ) {
echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
while getopts B oc ; do
case $ oc in
( B )
echo bfunc: B option
; ;
( * )
echo bfunc: odd option "($oc)"
; ;
esac
done
echo bfunc: leave
}
function kfunc {
echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
while getopts K oc ; do
case $ oc in
( K )
echo kfunc: K option
; ;
( * )
echo bfunc: odd option "($oc)"
; ;
esac
done
echo kfunc: leave
}
set - - - f - b - k - l
echo "line 1: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
bfunc - BBB blah
echo "line 3: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
kfunc - KKK blah
echo "line 5: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
echo
OPTIND = 1
set - - - fbkl
echo "line 10: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
bfunc - BBB blah
echo "line 30: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
kfunc - KKK blah
echo "line 50: OPTIND=$OPTIND"
getopts kbfl optc
echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
line 1 : OPTIND = 1
line 2 : ret = 0 , optc = f , OPTIND = 2
bfunc: enter ( args: - BBB blah ; OPTIND = 2 )
bfunc: B option
bfunc: B option
bfunc: leave
line 3 : OPTIND = 2
line 4 : ret = 0 , optc = b , OPTIND = 3
kfunc: enter ( args: - KKK blah ; OPTIND = 1 )
kfunc: K option
kfunc: K option
kfunc: K option
kfunc: leave
line 5 : OPTIND = 3
line 6 : ret = 0 , optc = k , OPTIND = 4
line 10 : OPTIND = 1
line 20 : ret = 0 , optc = f , OPTIND = 2
bfunc: enter ( args: - BBB blah ; OPTIND = 2 )
bfunc: B option
bfunc: B option
bfunc: leave
line 30 : OPTIND = 2
line 40 : ret = 1 , optc = ? , OPTIND = 2
kfunc: enter ( args: - KKK blah ; OPTIND = 1 )
kfunc: K option
kfunc: K option
kfunc: K option
kfunc: leave
line 50 : OPTIND = 2
line 60 : ret = 1 , optc = ? , OPTIND = 2
- - -
name: regression - 54
description:
Check that ; is not required before the then in if ( ( ... ) ) then ...
stdin:
if ( ( 1 ) ) then
echo ok dparen
fi
if [ [ - n 1 ] ] then
echo ok dbrackets
fi
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
ok dparen
ok dbrackets
- - -
name: regression - 55
description:
Check $ { foo: % bar } is allowed ( ksh88 allows it ... )
stdin:
x = fooXbarXblah
echo 1 $ { x % X * }
echo 2 $ { x: % X * }
echo 3 $ { x %% X * }
echo 4 $ { x: %% X * }
echo 5 $ { x #*X}
echo 6 $ { x: #*X}
echo 7 $ { x ##*X}
echo 8 $ { x: ##*X}
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
1 fooXbar
2 fooXbar
3 foo
4 foo
5 barXblah
6 barXblah
7 blah
8 blah
- - -
name: regression - 57
description:
Check if typeset output is correct for
2007-01-12 10:18:22 +00:00
uninitialised array elements .
2005-05-23 03:06:10 +00:00
stdin:
typeset - i xxx [ 4 ]
echo A
typeset - i | grep xxx | sed 's/^/ /'
echo B
typeset | grep xxx | sed 's/^/ /'
xxx [ 1 ] = 2 + 5
echo M
typeset - i | grep xxx | sed 's/^/ /'
echo N
typeset | grep xxx | sed 's/^/ /'
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
A
xxx
B
typeset - i xxx
M
xxx [ 1 ] = 7
N
2012-05-09 23:21:00 +00:00
set - A xxx
typeset - i xxx [ 1 ]
2005-05-23 03:06:10 +00:00
- - -
name: regression - 58
description:
Check if trap exit is ok ( exit not mistaken for signal name )
stdin:
trap 'echo hi' exit
trap exit 1
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
hi
- - -
name: regression - 59
description:
Check if $ { #array[*]} is calculated correctly.
stdin:
a [ 12 ] = hi
a [ 8 ] = there
echo $ { #a[*]}
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
2
- - -
name: regression - 60
description:
Check if default exit status is previous command
stdin:
( true ; exit )
echo A $?
( false ; exit )
echo B $?
( ( exit 103 ) ; exit )
echo C $?
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
A 0
B 1
C 103
- - -
name: regression - 61
description:
Check if EXIT trap is executed for sub shells .
stdin:
trap 'echo parent exit' EXIT
echo start
( echo A ; echo A last )
echo B
( echo C ; trap 'echo sub exit' EXIT ; echo C last )
echo parent last
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
start
A
A last
B
C
C last
sub exit
parent last
parent exit
- - -
name: regression - 62
description:
Check if test - nt / - ot succeeds if second ( first ) file is missing .
stdin:
touch a
test a - nt b && echo nt OK || echo nt BAD
test b - ot a && echo ot OK || echo ot BAD
2005-07-07 23:27:52 +00:00
expected - stdout:
2005-05-23 03:06:10 +00:00
nt OK
ot OK
- - -
2008-04-01 16:12:18 +00:00
name: regression - 63
description:
Check if typeset , export , and readonly work
stdin:
{
2009-10-02 18:08:37 +00:00
echo FNORD - 0
2008-04-01 16:12:18 +00:00
FNORD_A = 1
FNORD_B = 2
FNORD_C = 3
FNORD_D = 4
2008-04-01 21:39:45 +00:00
FNORD_E = 5
FNORD_F = 6
FNORD_G = 7
FNORD_H = 8
2008-04-01 21:07:20 +00:00
integer FNORD_E FNORD_F FNORD_G FNORD_H
export FNORD_C FNORD_D FNORD_G FNORD_H
readonly FNORD_B FNORD_D FNORD_F FNORD_H
2009-10-02 18:08:37 +00:00
echo FNORD - 1
2008-04-01 16:12:18 +00:00
export
2009-10-02 18:08:37 +00:00
echo FNORD - 2
2008-04-01 16:12:18 +00:00
export - p
2009-10-02 18:08:37 +00:00
echo FNORD - 3
2008-04-01 16:12:18 +00:00
readonly
2009-10-02 18:08:37 +00:00
echo FNORD - 4
2008-04-01 16:12:18 +00:00
readonly - p
2009-10-02 18:08:37 +00:00
echo FNORD - 5
2008-04-01 16:12:18 +00:00
typeset
2009-10-02 18:08:37 +00:00
echo FNORD - 6
2008-04-01 21:07:20 +00:00
typeset - p
2009-10-02 18:08:37 +00:00
echo FNORD - 7
2008-04-01 21:39:45 +00:00
typeset -
2009-10-02 18:08:37 +00:00
echo FNORD - 8
2008-04-01 16:12:18 +00:00
} | fgrep FNORD
2012-05-09 23:21:00 +00:00
fnord = ( 42 23 )
typeset - p fnord
echo FNORD - 9
2008-04-01 16:12:18 +00:00
expected - stdout:
FNORD - 0
FNORD - 1
FNORD_C
FNORD_D
2008-04-01 21:07:20 +00:00
FNORD_G
FNORD_H
2008-04-01 16:12:18 +00:00
FNORD - 2
export FNORD_C = 3
export FNORD_D = 4
2008-04-01 21:39:45 +00:00
export FNORD_G = 7
export FNORD_H = 8
2008-04-01 16:12:18 +00:00
FNORD - 3
FNORD_B
FNORD_D
2008-04-01 21:07:20 +00:00
FNORD_F
FNORD_H
2008-04-01 16:12:18 +00:00
FNORD - 4
readonly FNORD_B = 2
readonly FNORD_D = 4
2008-04-01 21:39:45 +00:00
readonly FNORD_F = 6
readonly FNORD_H = 8
2008-04-01 16:12:18 +00:00
FNORD - 5
typeset FNORD_A
typeset - r FNORD_B
typeset - x FNORD_C
typeset - x - r FNORD_D
2008-04-01 21:07:20 +00:00
typeset - i FNORD_E
typeset - i - r FNORD_F
typeset - i - x FNORD_G
typeset - i - x - r FNORD_H
2008-04-01 16:12:18 +00:00
FNORD - 6
2008-04-01 21:07:20 +00:00
typeset FNORD_A = 1
typeset - r FNORD_B = 2
typeset - x FNORD_C = 3
typeset - x - r FNORD_D = 4
typeset - i FNORD_E = 5
typeset - i - r FNORD_F = 6
typeset - i - x FNORD_G = 7
typeset - i - x - r FNORD_H = 8
FNORD - 7
FNORD_A = 1
FNORD_B = 2
FNORD_C = 3
FNORD_D = 4
2008-04-01 21:39:45 +00:00
FNORD_E = 5
FNORD_F = 6
FNORD_G = 7
FNORD_H = 8
2008-04-01 21:07:20 +00:00
FNORD - 8
2012-05-09 23:21:00 +00:00
set - A fnord
typeset fnord [ 0 ] = 42
typeset fnord [ 1 ] = 23
FNORD - 9
2008-04-01 16:12:18 +00:00
- - -
2008-07-14 12:29:06 +00:00
name: regression - 64
description:
Check that we can redefine functions calling time builtin
stdin:
t ( ) {
time > /dev/ null
}
t 2 > /dev/ null
t ( ) {
time
}
- - -
2011-02-13 21:13:08 +00:00
name: regression - 65
description:
check for a regression with sleep builtin and signal mask
2011-02-19 21:39:14 +00:00
category: ! nojsig
2011-02-13 21:13:08 +00:00
time - limit: 3
stdin:
sleep 1
echo blub | &
while read - p line ; do : ; done
echo ok
expected - stdout:
ok
- - -
2012-01-04 19:09:36 +00:00
name: regression - 66
description:
Check that quoting is sane
2012-11-25 22:23:31 +00:00
category: ! nojsig
2012-01-04 19:09:36 +00:00
stdin:
ac_space = ' '
ac_newline = '
'
set | grep ^ ac_ | &
set - A lines
while IFS = read - pr line ; do
if [ [ $ line = * space * ] ] ; then
lines [ 0 ] = $ line
else
lines [ 1 ] = $ line
fi
done
for line in "${lines[@]}" ; do
print - r - - "$line"
done
expected - stdout:
ac_space = ' '
ac_newline = $' \ n '
- - -
2011-03-27 18:50:06 +00:00
name: readonly - 0
description:
Ensure readonly is honoured for assignments and unset
stdin:
"$__progname" - c 'u=x; echo $? $u .' || echo aborted , $?
echo =
"$__progname" - c 'readonly u; u=x; echo $? $u .' || echo aborted , $?
echo =
"$__progname" - c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted , $?
expected - stdout:
0 x .
=
aborted , 2
=
1 x .
expected - stderr - pattern:
2011-12-16 20:03:28 +00:00
/read-only/
2011-03-27 18:50:06 +00:00
- - -
name: readonly - 1
description:
http: // austingroupbugs . net / view . php ? id = 367 for export
stdin:
"$__progname" - c 'readonly foo; export foo=a; echo $?' || echo aborted , $?
expected - stdout:
aborted , 2
expected - stderr - pattern:
2011-12-16 20:03:28 +00:00
/read-only/
2011-03-27 18:50:06 +00:00
- - -
name: readonly - 2 a
description:
Check that getopts works as intended , for readonly - 2 b to be valid
stdin:
"$__progname" - c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted , $?
expected - stdout:
0 a .
1 ? .
- - -
name: readonly - 2 b
description:
http: // austingroupbugs . net / view . php ? id = 367 for getopts
stdin:
"$__progname" - c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted , $?
expected - stdout:
2 .
expected - stderr - pattern:
2011-12-16 20:03:28 +00:00
/read-only/
2011-03-27 18:50:06 +00:00
- - -
name: readonly - 3
description:
http: // austingroupbugs . net / view . php ? id = 367 for read
stdin:
echo x | "$__progname" - c 'read s; echo $? $s .' || echo aborted , $?
echo y | "$__progname" - c 'readonly s; read s; echo $? $s .' || echo aborted , $?
expected - stdout:
0 x .
2 .
expected - stderr - pattern:
2011-12-16 20:03:28 +00:00
/read-only/
2011-03-27 18:50:06 +00:00
- - -
2014-02-09 00:08:17 +00:00
name: readonly - 4
description:
Do not permit bypassing readonly for first array item
stdin:
set - A arr - - foo bar
readonly arr
arr = baz
print - r - - "${arr[@]}"
expected - exit : e != 0
expected - stderr - pattern:
/read[ -]?only/
- - -
2005-05-23 03:06:10 +00:00
name: syntax - 1
description:
Check that lone ampersand is a syntax error
stdin:
&
expected - exit : e != 0
expected - stderr - pattern:
/syntax error/
- - -
name: xxx - quoted - newline - 1
description:
Check that \ <newline> works inside of $ { }
stdin:
abc = 2
echo $ { ab \
c }
expected - stdout:
2
- - -
name: xxx - quoted - newline - 2
description:
Check that \ <newline> works at the start of a here document
stdin:
cat << EO \
F
hi
EOF
expected - stdout:
hi
- - -
name: xxx - quoted - newline - 3
description:
Check that \ <newline> works at the end of a here document
stdin:
cat << EOF
hi
EO \
F
expected - stdout:
hi
- - -
name: xxx - multi - assignment - cmd
description:
Check that assignments in a command affect subsequent assignments
in the same command
stdin:
FOO = abc
FOO = 123 BAR = $ FOO
echo $ BAR
expected - stdout:
123
- - -
2010-04-08 13:21:08 +00:00
name: xxx - multi - assignment - posix - cmd
description:
Check that the behaviour for multiple assignments with a
command name matches POSIX . See:
http: // thread . gmane . org /gmane.comp.standards.posix.austin.general/ 1925
stdin:
X = a Y = b ; X = $ Y Y = $ X "$__progname" - c 'echo 1 $X $Y .' ; echo 2 $ X $ Y .
2010-04-09 14:46:43 +00:00
unset X Y Z
X = a Y = $ { X = b } Z = $ X "$__progname" - c 'echo 3 $Z .'
unset X Y Z
X = a Y = $ { X = b } Z = $ X ; echo 4 $ Z .
2010-04-08 13:21:08 +00:00
expected - stdout:
1 b a .
2 a b .
2010-04-09 14:46:43 +00:00
3 b .
4 a .
2010-04-08 13:21:08 +00:00
- - -
name: xxx - multi - assignment - posix - nocmd
description:
Check that the behaviour for multiple assignments with no
command name matches POSIX ( Debian #334182). See:
http: // thread . gmane . org /gmane.comp.standards.posix.austin.general/ 1925
stdin:
X = a Y = b ; X = $ Y Y = $ X ; echo 1 $ X $ Y .
expected - stdout:
1 b b .
- - -
name: xxx - multi - assignment - posix - subassign
description:
Check that the behaviour for multiple assignments matches POSIX:
- The assignment words shall be expanded in the current execution
environment .
- The assignments happen in the temporary execution environment .
stdin:
unset X Y Z
Z = a Y = $ { X: = b } sh - c 'echo +$X+ +$Y+ +$Z+'
echo /$X/
# Now for the special case:
unset X Y Z
X = Y = $ { X: = b } sh - c 'echo +$X+ +$Y+'
echo /$X/
expected - stdout:
+ + + b + + a +
/b/
+ + + b +
/b/
- - -
2005-05-23 03:06:10 +00:00
name: xxx - exec - environment - 1
description:
Check to see if exec sets it ' s environment correctly
stdin:
2012-03-31 18:18:41 +00:00
print '#!' "$__progname" '\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval ' \ '' print - r - - "$RANDOM=$'\''" $ RANDOM " ' \ ' \ " \ ' \ ; \
2015-07-10 19:36:38 +00:00
done > env ; chmod + x env ; PATH = . $ PATHSEP $ PATH
2005-05-23 03:06:10 +00:00
FOO = bar exec env
expected - stdout - pattern:
/(^|.*\n)FOO=bar\n/
- - -
name: xxx - exec - environment - 2
description:
Check to make sure exec doesn ' t change environment if a program
isn ' t exec - ed
stdin:
2012-03-31 18:18:41 +00:00
print '#!' "$__progname" '\nunset RANDOM\nexport | while IFS= read -r' \
'RANDOM; do eval ' \ '' print - r - - "$RANDOM=$'\''" $ RANDOM " ' \ ' \ " \ ' \ ; \
2015-07-10 19:36:38 +00:00
done > env ; chmod + x env ; PATH = . $ PATHSEP $ PATH
2012-03-31 18:18:41 +00:00
env > bar1
FOO = bar exec ; env > bar2
2005-05-23 03:06:10 +00:00
cmp - s bar1 bar2
- - -
2009-10-15 16:15:03 +00:00
name: exec - function - environment - 1
description:
Check assignments in function calls and whether they affect
the current execution environment ( ksh93 , SUSv4 )
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 -
- - -
2005-05-23 03:06:10 +00:00
name: xxx - what - do - you - call - this - 1
stdin:
echo "${foo:-" a "}*"
expected - stdout:
a *
- - -
name: xxx - prefix - strip - 1
stdin:
foo = 'a cdef'
echo $ { foo #a c}
expected - stdout:
def
- - -
name: xxx - prefix - strip - 2
stdin:
set a c
x = 'a cdef'
echo $ { x #$*}
expected - stdout:
def
- - -
name: xxx - variable - syntax - 1
stdin:
echo $ { : }
expected - stderr - pattern:
/bad substitution/
expected - exit : 1
- - -
2010-05-16 19:17:42 +00:00
name: xxx - variable - syntax - 2
stdin:
set 0
echo $ { * : 0 }
expected - stderr - pattern:
/bad substitution/
expected - exit : 1
- - -
name: xxx - variable - syntax - 3
stdin:
set - A foo 0
echo $ { foo [ * ] : 0 }
expected - stderr - pattern:
/bad substitution/
expected - exit : 1
- - -
2015-12-12 22:25:15 +00:00
name: xxx - variable - syntax - 4
description:
Not all kinds of trims are currently impossible , check those who do
stdin:
foo ( ) {
echo "<$*> X${*:+ }X"
}
foo a b
foo "" c
foo ""
foo "" ""
IFS = :
foo a b
foo "" c
foo ""
foo "" ""
IFS =
foo a b
foo "" c
foo ""
foo "" ""
expected - stdout:
< a b > X X
< c > X X
< > XX
< > X X
<a:b> X X
<:c> X X
< > XX
<:> X X
<ab> X X
<c> X X
< > XX
< > XX
- - -
2006-08-14 20:41:21 +00:00
name: xxx - substitution - eval - order
2005-05-23 03:06:10 +00:00
description:
Check order of evaluation of expressions
stdin:
i = 1 x = y =
set - A A abc def GHI j G k
echo $ { A [ x = ( i += 1 ) ] #${A[y=(i+=2)]}}
echo $ x $ y
expected - stdout:
HI
2 4
- - -
name: xxx - set - option - 1
description:
Check option parsing in set
stdin:
set - vsA foo - - A 1 3 2
echo $ { foo [ * ] }
expected - stderr:
echo $ { foo [ * ] }
expected - stdout:
1 2 3 A
- - -
name: xxx - exec - 1
description:
Check that exec exits for built - ins
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
2009-10-02 18:08:37 +00:00
exec echo hi
2005-05-23 03:06:10 +00:00
echo still herre
expected - stdout:
hi
expected - stderr - pattern: /.*/
- - -
name: xxx - while - 1
description:
Check the return value of while loops
XXX need to do same for for /select/ until loops
stdin:
i = x
while [ $ i != xxx ] ; do
i = x $ i
if [ $ i = xxx ] ; then
false
continue
fi
done
echo loop1 = $?
i = x
while [ $ i != xxx ] ; do
i = x $ i
if [ $ i = xxx ] ; then
false
break
fi
done
echo loop2 = $?
i = x
while [ $ i != xxx ] ; do
i = x $ i
false
done
echo loop3 = $?
expected - stdout:
loop1 = 0
loop2 = 0
loop3 = 1
- - -
name: xxx - status - 1
description:
Check that blank lines don ' t clear $?
2011-03-28 21:58:06 +00:00
need - ctty: yes
2005-05-23 03:06:10 +00:00
arguments: ! - i !
stdin:
( exit 1 )
echo $?
( exit 1 )
echo $?
true
expected - stdout:
1
1
expected - stderr - pattern: /.*/
- - -
name: xxx - status - 2
description:
Check that $? is preserved in subshells , includes , traps .
stdin:
( exit 1 )
echo blank: $?
( exit 2 )
( echo subshell: $? )
echo 'echo include: $?' > foo
( exit 3 )
. . / foo
trap 'echo trap: $?' ERR
( exit 4 )
echo exit : $?
expected - stdout:
blank: 1
subshell: 2
include: 3
trap: 4
exit : 4
- - -
name: xxx - clean - chars - 1
description:
Check MAGIC character is stuffed correctly
stdin:
echo `echo [<5B> `
expected - stdout:
[ <EFBFBD>
- - -
name: xxx - param - subst - qmark - 1
description:
Check suppresion of error message with null string . According to
POSIX , it shouldn 't print the error as ' word ' isn' t ommitted .
2015-10-09 17:48:53 +00:00
ksh88 /93, Solaris / bin /sh and / usr /xpg4/ bin / sh all print the error .
2005-05-23 03:06:10 +00:00
stdin:
unset foo
x =
echo x $ { foo ? $ x }
expected - exit : 1
2015-10-09 17:48:53 +00:00
expected - stderr - pattern: ! /not set/
2005-05-23 03:06:10 +00:00
- - -
name: xxx - param - _ - 1
2007-07-01 19:04:53 +00:00
# fails due to weirdness of execv stuff
category: ! os:uwin - nt
2005-05-23 03:06:10 +00:00
description:
Check c flag is set .
arguments: ! - c ! echo "[$-]" !
expected - stdout - pattern: /^\[.*c.*\]$/
- - -
2005-05-25 14:20:53 +00:00
name: tilde - expand - 1
description:
Check tilde expansion after equal signs
env - setup: ! HOME = / sweet !
stdin:
echo $ { A = a = } ~ b =~ c = d ~ ~
2016-01-19 23:12:15 +00:00
export e =~ f = d ~
command command export g =~ h = d ~
echo ". $e . $f ."
echo ". $g . $h ."
2015-10-09 17:48:53 +00:00
set - o posix
2016-01-19 23:12:15 +00:00
unset A e f g h
2005-05-25 14:20:53 +00:00
echo $ { A = a = } ~ b =~ c = d ~ ~
2016-01-19 23:12:15 +00:00
export e =~ f = d ~
command command export g =~ h = d ~
echo ". $e . $f ."
echo ". $g . $h ."
2005-05-25 14:20:53 +00:00
expected - stdout:
a = /sweet b=/s weet c = d ~ / sweet
2016-01-19 23:12:15 +00:00
. / sweet . d ~ .
. / sweet . d ~ .
2005-05-25 14:20:53 +00:00
a =~ b =~ c = d ~ / sweet
2016-01-19 23:12:15 +00:00
. / sweet . d ~ .
. / sweet . d ~ .
2005-05-25 14:20:53 +00:00
- - -
2012-11-12 19:13:46 +00:00
name: tilde - expand - 2
description:
Check tilde expansion works
env - setup: ! HOME = / sweet !
stdin:
wd = $ PWD
cd /
plus = $ ( print - r - - ~ + )
minus = $ ( print - r - - ~ - )
nix = $ ( print - r - - ~ )
[ [ $ plus = / ] ] ; echo one $? .
[ [ $ minus = "$wd" ] ] ; echo two $? .
[ [ $ nix = / sweet ] ] ; echo nix $? .
expected - stdout:
one 0 .
two 0 .
nix 0 .
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 1
2005-05-25 14:39:33 +00:00
description:
Check some "exit on error" conditions
stdin:
2012-03-31 18:18:41 +00:00
print '#!' "$__progname" '\nexec "$1"' > env
print '#!' "$__progname" '\nexit 1' > false
chmod + x env false
2015-07-10 19:36:38 +00:00
PATH = . $ PATHSEP $ PATH
2005-05-25 14:39:33 +00:00
set - ex
2011-04-09 15:39:50 +00:00
env false && echo something
2005-05-25 14:39:33 +00:00
echo END
expected - stdout:
END
expected - stderr:
2013-04-26 19:40:45 +00:00
+ env false
+ echo END
2005-05-25 14:39:33 +00:00
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 2
2005-05-25 14:39:33 +00:00
description:
2009-03-22 15:47:23 +00:00
Check some "exit on error" edge conditions ( POSIXly )
2005-05-25 14:39:33 +00:00
stdin:
2012-03-31 18:18:41 +00:00
print '#!' "$__progname" '\nexec "$1"' > env
print '#!' "$__progname" '\nexit 1' > false
print '#!' "$__progname" '\nexit 0' > true
chmod + x env false
2015-07-10 19:36:38 +00:00
PATH = . $ PATHSEP $ PATH
2005-05-25 14:39:33 +00:00
set - ex
2011-04-09 15:39:50 +00:00
if env true ; then
env false && echo something
2005-05-25 14:39:33 +00:00
fi
echo END
expected - stdout:
2009-03-22 15:47:23 +00:00
END
2005-05-25 14:39:33 +00:00
expected - stderr:
2013-04-26 19:40:45 +00:00
+ env true
+ env false
+ echo END
2005-05-25 14:39:33 +00:00
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 3
2007-07-24 11:22:04 +00:00
description:
pdksh regression which AT & T ksh does right
TFM says: [ set ] - e | errexit
Exit ( after executing the ERR trap ) ...
stdin:
trap 'echo EXIT' EXIT
trap 'echo ERR' ERR
set - e
cd /XXXXX 2>/ dev / null
echo DONE
exit 0
expected - stdout:
ERR
EXIT
expected - exit : e != 0
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 4
2009-03-22 15:47:23 +00:00
description:
"set -e" test suite ( POSIX )
stdin:
set - e
echo pre
if true ; then
false && echo foo
fi
echo bar
expected - stdout:
pre
bar
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 5
2009-03-22 15:47:23 +00:00
description:
"set -e" test suite ( POSIX )
stdin:
set - e
foo ( ) {
while [ "$1" ] ; do
for E in $ x ; do
[ "$1" = "$E" ] && { shift ; continue 2 ; }
done
x = "$x $1"
shift
done
echo $ x
}
echo pre
foo a b b c
echo post
expected - stdout:
pre
a b c
post
- - -
2009-10-14 18:04:52 +00:00
name: exit - err - 6
2009-03-22 15:47:23 +00:00
description:
"set -e" test suite ( BSD make )
category: os:mirbsd
stdin:
mkdir zd zd /a zd/ b
2009-03-22 18:28:35 +00:00
print 'all:\n\t@echo eins\n\t@exit 42\n' > zd /a/ Makefile
print 'all:\n\t@echo zwei\n' > zd /b/ Makefile
2009-03-22 15:47:23 +00:00
wd = $ ( pwd )
set - e
for entry in a b ; do ( set - e ; if [ [ - d $ wd /zd/ $ entry . i386 ] ] ; then _newdir_ = "$entry.i386" ; else _newdir_ = "$entry" ; fi ; if [ [ - z $ _THISDIR_ ] ] ; then _nextdir_ = "$_newdir_" ; else _nextdir_ = "$_THISDIR_/$_newdir_" ; fi ; _makefile_spec_ = ; [ [ ! - f $ wd /zd/ $ _newdir_ /Makefile.bsd-wrapper ]] || _makefile_spec_="-f Makefile.bsd-wrapper"; subskipdir=; for skipdir in ; do subentry=${skipdir#$entry}; if [[ $subentry != $skipdir ]]; then if [[ -z $subentry ]]; then echo "($_nextdir_ skipped)"; break; fi; subskipdir="$subskipdir ${subentry#/ } "; fi; done; if [[ -z $skipdir || -n $subentry ]]; then echo " === > $ _nextdir_ "; cd $wd/zd/$_newdir_; make SKIPDIR=" $ subskipdir " $_makefile_spec_ _THISDIR_=" $ _nextdir_ " all; fi; ) done 2>&1 | sed " s!$wd!WD!g "
expected - stdout:
=== > a
eins
** * Error code 42
Stop in WD /zd/ a ( line 2 of Makefile ) .
- - -
2013-02-10 23:59:28 +00:00
name: exit - err - 7
description:
"set -e" regression ( LP #1104543)
stdin:
set - e
bla ( ) {
[ - x $ PWD /nonexistant ] && $PWD/ nonexistant
}
echo x
bla
echo y $?
expected - stdout:
x
expected - exit : 1
- - -
2013-02-15 18:50:14 +00:00
name: exit - err - 8
description:
"set -e" regression ( Debian #700526)
stdin:
set - e
_db_cmd ( ) { return $ 1 ; }
db_input ( ) { _db_cmd 30 ; }
db_go ( ) { _db_cmd 0 ; }
db_input || :
db_go
exit 0
- - -
2009-10-14 18:04:52 +00:00
name: exit - enoent - 1
description:
SUSv4 says that the shell should exit with 126 / 127 in some situations
stdin:
i = 0
( echo ; echo : ) > x
"$__progname" . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
"$__progname" - c . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
echo exit 42 > x
"$__progname" . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
"$__progname" - c . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
rm - f x
"$__progname" . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
"$__progname" - c . /x >/ dev / null 2 > & 1 ; r = $? ; echo $( ( i + + ) ) $ r .
expected - stdout:
0 0 .
1 126 .
2 42 .
3 126 .
4 127 .
5 127 .
- - -
2009-10-14 18:06:57 +00:00
name: exit - eval - 1
description:
Check eval vs substitution exit codes ( ksh93 alike )
stdin:
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval $ ( false )
echo A $?
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval ' $(false)'
echo B $?
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval " $(false)"
echo C $?
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval "eval $(false)"
echo D $?
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval 'eval ' "$(false)"
echo E $?
IFS = "$IFS:"
2012-10-21 21:55:05 +00:00
( exit 12 )
2009-10-14 18:06:57 +00:00
eval $ ( echo : ; false )
echo F $?
2012-10-21 21:55:05 +00:00
echo - n "G "
( exit 12 )
eval 'echo $?'
echo H $?
2009-10-14 18:06:57 +00:00
expected - stdout:
A 0
B 1
C 0
D 0
E 0
F 0
2012-10-21 21:55:05 +00:00
G 12
H 0
2009-10-14 18:06:57 +00:00
- - -
2010-11-01 17:29:05 +00:00
name: exit - trap - 1
description:
Check that "exit" with no arguments behaves SUSv4 conformant .
stdin:
trap 'echo hi; exit' EXIT
exit 9
expected - stdout:
hi
expected - exit : 9
- - -
2013-01-01 20:45:04 +00:00
name: exit - trap - 2
description:
Check that ERR and EXIT traps are run just like ksh93 does .
2013-01-01 22:23:16 +00:00
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 .
2013-01-01 20:45:04 +00:00
file - setup: file 644 "x"
v = ; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
2013-01-01 22:23:16 +00:00
set $ 1
echo "and run $2"
eval $ 2
2013-01-01 20:45:04 +00:00
echo and out
file - setup: file 644 "xt"
v = ; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
2013-01-01 22:23:16 +00:00
set $ 1
2013-01-01 20:45:04 +00:00
echo 'and run true'
true
echo and out
file - setup: file 644 "xf"
v = ; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
2013-01-01 22:23:16 +00:00
set $ 1
2013-01-01 20:45:04 +00:00
echo 'and run false'
false
echo and out
file - setup: file 644 "xu"
v = ; unset v
trap 'echo EXtrap' EXIT
trap 'echo ERtrap' ERR
2013-01-01 22:23:16 +00:00
set $ 1
2013-01-01 20:45:04 +00:00
echo 'and run ${v?}'
$ { v ? }
echo and out
stdin:
runtest ( ) {
rm - f rc
(
"$__progname" "$@"
echo $? > rc
) 2 > & 1 | sed \
- e 's/parameter not set/parameter null or not set/' \
- e 's/[[]6]//' - e 's/: eval: line 1//' - e 's/: line 6//' \
- e "s ^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*] PROG "
}
2013-01-01 22:23:16 +00:00
xe = - e
echo : $ xe
runtest x $ xe true
echo = eval - true $( < rc ) .
runtest x $ xe false
echo = eval - false $( < rc ) .
runtest x $ xe '${v?}'
echo = eval - undef $( < rc ) .
runtest xt $ xe
echo = noeval - true $( < rc ) .
runtest xf $ xe
echo = noeval - false $( < rc ) .
runtest xu $ xe
echo = noeval - undef $( < rc ) .
xe = + e
echo : $ xe
runtest x $ xe true
2013-01-01 20:45:04 +00:00
echo = eval - true $( < rc ) .
2013-01-01 22:23:16 +00:00
runtest x $ xe false
2013-01-01 20:45:04 +00:00
echo = eval - false $( < rc ) .
2013-01-01 22:23:16 +00:00
runtest x $ xe '${v?}'
2013-01-01 20:45:04 +00:00
echo = eval - undef $( < rc ) .
2013-01-01 22:23:16 +00:00
runtest xt $ xe
2013-01-01 20:45:04 +00:00
echo = noeval - true $( < rc ) .
2013-01-01 22:23:16 +00:00
runtest xf $ xe
2013-01-01 20:45:04 +00:00
echo = noeval - false $( < rc ) .
2013-01-01 22:23:16 +00:00
runtest xu $ xe
2013-01-01 20:45:04 +00:00
echo = noeval - undef $( < rc ) .
expected - stdout:
2013-01-01 22:23:16 +00:00
: - e
2013-01-01 20:45:04 +00:00
and run true
and out
EXtrap
= eval - true 0 .
and run false
ERtrap
EXtrap
= eval - false 1 .
and run $ { v ? }
x: v: parameter null or not set
ERtrap
EXtrap
= eval - undef 1 .
and run true
and out
EXtrap
= noeval - true 0 .
and run false
ERtrap
EXtrap
= noeval - false 1 .
and run $ { v ? }
xu: v: parameter null or not set
EXtrap
= noeval - undef 1 .
2013-01-01 22:23:16 +00:00
: + e
and run true
and out
EXtrap
= eval - true 0 .
and run false
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
and out
EXtrap
= noeval - true 0 .
and run false
ERtrap
and out
EXtrap
= noeval - false 0 .
and run $ { v ? }
xu: v: parameter null or not set
EXtrap
= noeval - undef 1 .
2013-01-01 20:45:04 +00:00
- - -
2013-07-25 16:41:30 +00:00
name: exit - trap - interactive
description:
Check that interactive shell doesn ' t exit via EXIT trap on syntax error
arguments: ! - i !
stdin:
trap - - EXIT
echo Syntax error <
echo 'After error 1'
trap 'echo Exit trap' EXIT
echo Syntax error <
echo 'After error 2'
trap 'echo Exit trap' EXIT
exit
echo 'After exit'
expected - stdout:
After error 1
After error 2
Exit trap
expected - stderr - pattern:
/syntax error: 'newline' unexpected/
- - -
2006-08-14 20:41:21 +00:00
name: test - stlt - 1
2005-10-08 19:31:00 +00:00
description:
Check that test also can handle string1 < string2 etc .
stdin:
test 2005 /10/ 08 '<' 2005 /08/ 21 && echo ja || echo nein
test 2005 /08/ 21 \ < 2005 /10/ 08 && echo ja || echo nein
2006-08-14 20:41:21 +00:00
test 2005 /10/ 08 '>' 2005 /08/ 21 && echo ja || echo nein
test 2005 /08/ 21 \ > 2005 /10/ 08 && echo ja || echo nein
2005-10-08 19:31:00 +00:00
expected - stdout:
nein
ja
2006-08-14 20:41:21 +00:00
ja
nein
2005-10-08 19:31:00 +00:00
expected - stderr - pattern: ! /unexpected op/
- - -
2009-03-22 18:28:35 +00:00
name: test - precedence - 1
description:
Check a weird precedence case ( and POSIX echo )
stdin:
test \ ( - f = - f \ )
rv = $?
2013-02-19 18:45:22 +00:00
echo $ rv
2009-03-22 18:28:35 +00:00
expected - stdout:
2013-02-19 18:45:22 +00:00
0
2009-03-22 18:28:35 +00:00
- - -
2009-09-07 17:24:49 +00:00
name: test - option - 1
description:
Test the test - o operator
stdin:
runtest ( ) {
test - o $ 1 ; echo $?
[ - o $ 1 ] ; echo $?
[ [ - o $ 1 ] ] ; echo $?
}
if_test ( ) {
test - o $ 1 - o - o ! $ 1 ; echo $?
[ - o $ 1 - o - o ! $ 1 ] ; echo $?
[ [ - o $ 1 || - o ! $ 1 ] ] ; echo $?
test - o ? $ 1 ; echo $?
}
echo 0 y $ ( if_test utf8 - mode ) =
echo 0 n $ ( if_test utf8 - hack ) =
echo 1 = $ ( runtest utf8 - hack ) =
echo 2 = $ ( runtest ! utf8 - hack ) =
echo 3 = $ ( runtest ? utf8 - hack ) =
set + U
echo 1 + $ ( runtest utf8 - mode ) =
echo 2 + $ ( runtest ! utf8 - mode ) =
echo 3 + $ ( runtest ? utf8 - mode ) =
set - U
echo 1 - $ ( runtest utf8 - mode ) =
echo 2 - $ ( runtest ! utf8 - mode ) =
echo 3 - $ ( runtest ? utf8 - mode ) =
2010-01-01 18:02:01 +00:00
echo = short flags =
echo 0 y $ ( if_test - U ) =
echo 0 y $ ( if_test + U ) =
echo 0 n $ ( if_test - _ ) =
echo 0 n $ ( 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 ) =
2009-09-07 17:24:49 +00:00
expected - stdout:
0 y 0 0 0 0 =
0 n 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 - 0 0 0 =
2 - 1 1 1 =
3 - 0 0 0 =
2010-01-01 18:02:01 +00:00
= short flags =
0 y 0 0 0 0 =
0 y 0 0 0 0 =
0 n 1 1 1 1 =
0 n 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 =
2009-09-07 17:24:49 +00:00
- - -
2015-12-12 16:37:44 +00:00
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
- - -
2015-12-12 22:25:15 +00:00
name: test - numeq
description:
Check numeric - eq works ( R40d regression ) ; spotted by Martijn Dekker
stdin:
tst ( ) {
eval "$2"
case $? in
( 0 ) echo yepp 0 \ #"$*" ;;
( 1 ) echo nope 1 \ #"$*" ;;
( 2 ) echo terr 2 \ #"$*" ;;
( * ) echo wtf \ ? $? \ #"$*" ;;
esac
}
tst 1 'test 2 -eq 2'
tst 2 'test 2 -eq 2a'
tst 3 'test 2 -eq 3'
tst 4 'test 2 -ne 2'
tst 5 'test 2 -ne 2a'
tst 6 'test 2 -ne 3'
tst 7 'test \! 2 -eq 2'
tst 8 'test \! 2 -eq 2a'
tst 9 'test \! 2 -eq 3'
expected - stdout:
yepp 0 #1 test 2 -eq 2
terr 2 #2 test 2 -eq 2a
nope 1 #3 test 2 -eq 3
nope 1 #4 test 2 -ne 2
terr 2 #5 test 2 -ne 2a
yepp 0 #6 test 2 -ne 3
nope 1 #7 test \! 2 -eq 2
terr 2 #8 test \! 2 -eq 2a
yepp 0 #9 test \! 2 -eq 3
expected - stderr - pattern:
/bad number/
- - -
2006-05-08 11:59:41 +00:00
name: mkshrc - 1
description:
Check that ~ / . mkshrc works correctly .
Part 1 : verify user environment is not read ( internal )
stdin:
echo x $ FNORD
expected - stdout:
x
- - -
2006-06-21 19:27:35 +00:00
name: mkshrc - 2 a
2006-05-08 11:59:41 +00:00
description:
Check that ~ / . mkshrc works correctly .
2006-06-21 19:27:35 +00:00
Part 2 : verify mkshrc is not read ( non - interactive shells )
2006-05-08 11:59:41 +00:00
file - setup: file 644 ".mkshrc"
FNORD = 42
env - setup: ! HOME = . ! ENV = !
2006-06-21 19:27:35 +00:00
stdin:
echo x $ FNORD
expected - stdout:
x
- - -
name: mkshrc - 2 b
description:
Check that ~ / . mkshrc works correctly .
Part 2 : verify mkshrc can be read ( interactive shells )
file - setup: file 644 ".mkshrc"
FNORD = 42
2011-03-28 21:58:06 +00:00
need - ctty: yes
2006-06-21 19:27:35 +00:00
arguments: ! - i !
env - setup: ! HOME = . ! ENV = ! PS1 = !
2006-05-08 11:59:41 +00:00
stdin:
echo x $ FNORD
expected - stdout:
x 42
2006-07-07 09:52:20 +00:00
expected - stderr - pattern:
/(# )*/
2006-05-08 11:59:41 +00:00
- - -
name: mkshrc - 3
description:
Check that ~ / . mkshrc works correctly .
Part 3 : verify mkshrc can be turned off
file - setup: file 644 ".mkshrc"
FNORD = 42
env - setup: ! HOME = . ! ENV = nonexistant !
stdin:
echo x $ FNORD
expected - stdout:
x
- - -
2009-10-02 18:08:37 +00:00
name: sh - mode - 1
2006-08-09 20:21:08 +00:00
description:
2009-10-02 18:08:37 +00:00
Check that sh mode turns braceexpand off
2006-08-09 20:21:08 +00:00
and that that works correctly
stdin:
set - o braceexpand
2009-10-02 18:08:37 +00:00
set + o sh
[ [ $ ( set + o ) == * @ ( - o sh ) @ ( | * ) ] ] && echo sh || echo nosh
2008-04-19 22:03:19 +00:00
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 20:21:08 +00:00
echo { a , b , c }
set + o braceexpand
echo { a , b , c }
set - o braceexpand
echo { a , b , c }
2009-10-02 18:08:37 +00:00
set - o sh
2006-08-09 20:21:08 +00:00
echo { a , b , c }
2009-10-02 18:08:37 +00:00
[ [ $ ( set + o ) == * @ ( - o sh ) @ ( | * ) ] ] && echo sh || echo nosh
2008-04-19 22:03:19 +00:00
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 20:21:08 +00:00
set - o braceexpand
echo { a , b , c }
2009-10-02 18:08:37 +00:00
[ [ $ ( set + o ) == * @ ( - o sh ) @ ( | * ) ] ] && echo sh || echo nosh
2008-04-19 22:03:19 +00:00
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 20:21:08 +00:00
expected - stdout:
2009-10-02 18:08:37 +00:00
nosh
2006-08-09 20:21:08 +00:00
brex
a b c
{ a , b , c }
a b c
{ a , b , c }
2009-10-02 18:08:37 +00:00
sh
2006-08-09 20:21:08 +00:00
nobrex
a b c
2009-10-02 18:08:37 +00:00
sh
2006-08-09 20:21:08 +00:00
brex
- - -
2009-10-02 18:08:37 +00:00
name: sh - mode - 2 a
2008-10-20 19:29:25 +00:00
description:
2013-05-02 20:21:45 +00:00
Check that posix or sh mode is * not * automatically turned on
2008-10-20 19:29:25 +00:00
category: ! binsh
stdin:
2012-05-04 21:42:51 +00:00
ln - s "$__progname" ksh || cp "$__progname" ksh
ln - s "$__progname" sh || cp "$__progname" sh
ln - s "$__progname" . /-ksh || cp "$__progname" ./ - ksh
ln - s "$__progname" . /-sh || cp "$__progname" ./ - sh
2008-10-20 19:29:25 +00:00
for shell in { , - } { , k } sh ; do
print - - $ shell $( . / $ shell + l - c \
2013-05-02 20:21:45 +00:00
'[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh' )
2008-10-20 19:29:25 +00:00
done
expected - stdout:
2009-10-02 18:08:37 +00:00
sh nosh
ksh nosh
- sh nosh
- ksh nosh
2008-10-20 19:29:25 +00:00
- - -
2009-10-02 18:08:37 +00:00
name: sh - mode - 2 b
2008-09-17 19:31:30 +00:00
description:
2013-05-02 20:21:45 +00:00
Check that posix or sh mode * is * automatically turned on
2008-10-20 19:29:25 +00:00
category: binsh
2008-09-17 19:31:30 +00:00
stdin:
2012-05-04 21:42:51 +00:00
ln - s "$__progname" ksh || cp "$__progname" ksh
ln - s "$__progname" sh || cp "$__progname" sh
ln - s "$__progname" . /-ksh || cp "$__progname" ./ - ksh
ln - s "$__progname" . /-sh || cp "$__progname" ./ - sh
2008-09-17 19:31:30 +00:00
for shell in { , - } { , k } sh ; do
print - - $ shell $( . / $ shell + l - c \
2013-05-02 20:21:45 +00:00
'[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh' )
2008-09-17 19:31:30 +00:00
done
expected - stdout:
2009-10-02 18:08:37 +00:00
sh sh
ksh nosh
- sh sh
- ksh nosh
2008-09-17 19:31:30 +00:00
- - -
2007-10-25 13:51:19 +00:00
name: pipeline - 1
2006-08-14 20:36:39 +00:00
description:
pdksh bug: last command of a pipeline is executed in a
subshell - make sure it still is , scripts depend on it
file - setup: file 644 "abcx"
file - setup: file 644 "abcy"
stdin:
echo *
echo a | while read d ; do
echo $ d
echo $ d *
echo *
set - o noglob
echo $ d *
echo *
done
echo *
expected - stdout:
abcx abcy
a
abcx abcy
abcx abcy
a *
*
abcx abcy
- - -
2007-10-25 13:51:19 +00:00
name: pipeline - 2
description:
check that co - processes work with TCOMs , TPIPEs and TPARENs
2011-01-30 01:35:35 +00:00
category: ! nojsig
2007-10-25 13:51:19 +00:00
stdin:
2009-10-02 18:08:37 +00:00
"$__progname" - c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
"$__progname" - c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
"$__progname" - c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
2007-10-25 13:51:19 +00:00
expected - stdout:
100 hi
200 hi
300 hi
- - -
2011-02-18 22:26:13 +00:00
name: pipeline - 3
description:
Check that PIPESTATUS does what it ' s supposed to
stdin:
echo 1 $ PIPESTATUS .
echo 2 $ { PIPESTATUS [ 0 ] } .
echo 3 $ { PIPESTATUS [ 1 ] } .
( echo x ; exit 12 ) | ( cat ; exit 23 ) | ( cat ; exit 42 )
echo 5 $? , $ PIPESTATUS , $ { PIPESTATUS [ 0 ] } , $ { PIPESTATUS [ 1 ] } , $ { PIPESTATUS [ 2 ] } , $ { PIPESTATUS [ 3 ] } .
echo 6 $ { PIPESTATUS [ 0 ] } .
set | fgrep PIPESTATUS
echo 8 $ ( set | fgrep PIPESTATUS ) .
expected - stdout:
1 0 .
2 0 .
3 .
x
5 42 , 12 , 12 , 23 , 42 , .
6 0 .
PIPESTATUS [ 0 ] = 0
8 PIPESTATUS [ 0 ] = 0 PIPESTATUS [ 1 ] = 0 .
- - -
2013-05-02 20:28:15 +00:00
name: pipeline - 4
description:
Check that "set -o pipefail" does what it ' s supposed to
stdin:
echo 1 "$(" $ __progname " -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 2 "$(" $ __progname " -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 3 "$(" $ __progname " -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 4 "$(" $ __progname " -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
echo 5 "$(" $ __progname " -c '(exit 23) | (exit 42) | :; echo $?')" .
echo 6 "$(" $ __progname " -c '! (exit 23) | (exit 42) | :; echo $?')" .
echo 7 "$(" $ __progname " -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
echo 8 "$(" $ __progname " -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
2014-06-10 22:17:10 +00:00
echo 9 "$(" $ __progname " -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
2013-05-02 20:28:15 +00:00
expected - stdout:
1 42 .
2 0 .
3 42 .
4 0 .
5 0 .
6 1 .
7 42 .
8 0 .
2014-06-10 22:17:10 +00:00
9 42 .
2013-05-02 20:28:15 +00:00
- - -
2006-08-24 20:50:02 +00:00
name: persist - history - 1
description:
Check if persistent history saving works
2008-06-21 19:20:15 +00:00
category: ! no - histfile
2011-03-28 21:58:06 +00:00
need - ctty: yes
2006-08-24 20:50:02 +00:00
arguments: ! - i !
env - setup: ! ENV = . / Env ! HISTFILE = hist . file !
file - setup: file 644 "Env"
PS1 = X
stdin:
cat hist . file
expected - stdout - pattern:
/cat hist.file/
expected - stderr - pattern:
/^X*$/
- - -
2011-07-05 20:12:20 +00:00
name: typeset - 1
description:
Check that global does what typeset is supposed to do
stdin:
set - A arrfoo 65
foo ( ) {
global - Uui16 arrfoo [ * ]
}
echo before $ { arrfoo [ 0 ] } .
foo
echo after $ { arrfoo [ 0 ] } .
set - A arrbar 65
bar ( ) {
echo inside before $ { arrbar [ 0 ] } .
arrbar [ 0 ] = 97
echo inside changed $ { arrbar [ 0 ] } .
global - Uui16 arrbar [ * ]
echo inside typeset $ { arrbar [ 0 ] } .
arrbar [ 0 ] = 48
echo inside changed $ { arrbar [ 0 ] } .
}
echo before $ { arrbar [ 0 ] } .
bar
echo after $ { arrbar [ 0 ] } .
expected - stdout:
before 65 .
after 16 #41 .
before 65 .
inside before 65 .
inside changed 97 .
inside typeset 16 #61 .
inside changed 16 #30 .
after 16 #30 .
- - -
2006-11-10 01:13:52 +00:00
name: typeset - padding - 1
description:
Check if left / right justification works as per TFM
stdin:
typeset - L10 ln = 0 hall0
typeset - R10 rn = 0 hall0
typeset - ZL10 lz = 0 hall0
typeset - ZR10 rz = 0 hall0
typeset - Z10 rx = " hallo "
2009-10-02 18:08:37 +00:00
echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
2006-11-10 01:13:52 +00:00
expected - stdout:
< 0 hall0 > < 0 hall0 > < hall0 > <00000hall0> < 0000 hallo >
- - -
2008-04-19 21:04:09 +00:00
name: typeset - padding - 2
description:
Check if base - ! 10 integers are padded right
stdin:
typeset - Uui16 - L9 ln = 16 #1
typeset - Uui16 - R9 rn = 16 #1
typeset - Uui16 - Z9 zn = 16 #1
typeset - L9 ls = 16 #1
typeset - R9 rs = 16 #1
typeset - Z9 zs = 16 #1
2009-10-02 18:08:37 +00:00
echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
2008-04-19 21:04:09 +00:00
expected - stdout:
< 16 #1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
- - -
2007-04-15 10:45:59 +00:00
name: utf8bom - 1
description:
Check that the UTF - 8 Byte Order Mark is ignored as the first
multibyte character of the shell input ( with - c , from standard
input , as file , or as eval argument ) , but nowhere else
2007-04-23 21:46:12 +00:00
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2008-06-21 19:20:15 +00:00
category: ! os:darwin
2007-04-15 10:45:59 +00:00
stdin:
mkdir foo
print '#!/bin/sh\necho ohne' > foo / fnord
print '#!/bin/sh\necho mit' > foo / fnord
print ' fnord\nfnord\n fnord\nfnord' > foo / bar
print eval \ '' fnord \ nfnord \ n fnord \ nfnord ' \ ' > foo / zoo
set - A anzahl - - foo / *
2009-10-02 18:08:37 +00:00
echo got $ { #anzahl[*]} files
2007-04-15 10:45:59 +00:00
chmod + x foo / *
2015-07-10 19:36:38 +00:00
export PATH = $ ( pwd ) / foo $ PATHSEP $ PATH
2008-04-01 16:01:45 +00:00
"$__progname" - c ' fnord'
2009-04-08 18:00:53 +00:00
echo =
2008-04-01 16:01:45 +00:00
"$__progname" - c ' fnord; fnord; fnord; fnord'
2009-04-08 18:00:53 +00:00
echo =
2008-04-01 16:01:45 +00:00
"$__progname" foo / bar
2009-04-08 18:00:53 +00:00
echo =
2008-04-01 16:01:45 +00:00
"$__progname" < foo / bar
2009-04-08 18:00:53 +00:00
echo =
2008-04-01 16:01:45 +00:00
"$__progname" foo / zoo
2009-04-08 18:00:53 +00:00
echo =
2009-10-02 18:08:37 +00:00
"$__progname" - c 'echo : $( fnord)'
2007-04-15 10:45:59 +00:00
rm - rf foo
expected - stdout:
got 4 files
ohne
2009-04-08 18:00:53 +00:00
=
2007-04-15 10:45:59 +00:00
ohne
ohne
mit
ohne
2009-04-08 18:00:53 +00:00
=
2007-04-15 10:45:59 +00:00
ohne
ohne
mit
ohne
2009-04-08 18:00:53 +00:00
=
2007-04-15 10:45:59 +00:00
ohne
ohne
mit
ohne
2009-04-08 18:00:53 +00:00
=
2007-04-15 10:45:59 +00:00
ohne
ohne
mit
ohne
2009-04-08 18:00:53 +00:00
=
2011-03-13 16:03:54 +00:00
: ohne
2007-04-15 10:45:59 +00:00
- - -
2008-04-01 17:25:37 +00:00
name: utf8bom - 2
2007-04-15 10:58:55 +00:00
description:
2009-04-08 18:00:53 +00:00
Check that we can execute BOM - shebangs ( failures not fatal )
2007-04-15 12:09:57 +00:00
XXX if the OS can already execute them , we lose
2007-04-17 14:00:00 +00:00
note: cygwin execve ( 2 ) doesn ' t return to us with ENOEXEC , we lose
2008-04-02 17:09:45 +00:00
note: Ultrix perl5 t4 returns 65280 ( exit - code 255 ) and no text
2014-11-25 21:13:31 +00:00
XXX fails when LD_PRELOAD is set with - e and Perl chokes it ( ASan )
2011-05-29 02:18:57 +00:00
need - pass: no
2011-11-05 23:39:02 +00:00
category: ! os:cygwin , ! os:msys , ! os:ultrix , ! os:uwin - nt , ! smksh
2008-04-01 17:22:54 +00:00
env - setup: ! FOO = BAR !
stdin:
2009-04-08 18:00:53 +00:00
print '#!' "$__progname" '\nprint "1 a=$ENV{FOO}";' > t1
print ' #!' "$__progname" '\nprint "2 a=$ENV{FOO}";' > t2
print '#!' "$__perlname" '\nprint "3 a=$ENV{FOO}\n";' > t3
print ' #!' "$__perlname" '\nprint "4 a=$ENV{FOO}\n";' > t4
2008-04-01 17:22:54 +00:00
chmod + x t ?
. / t1
. / t2
. / t3
. / t4
expected - stdout:
2009-04-08 18:00:53 +00:00
1 a = / nonexistant { FOO }
2 a = / nonexistant { FOO }
3 a = BAR
4 a = BAR
2008-04-01 17:22:54 +00:00
expected - stderr - pattern:
2008-04-01 17:25:37 +00:00
/(Unrecognized character .... ignored at \..t4 line 1)*/
2008-04-01 17:22:54 +00:00
- - -
2008-07-08 20:54:33 +00:00
name: utf8opt - 1 a
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
description:
2008-12-04 18:11:08 +00:00
Check that the utf8 - mode flag is not set at non - interactive startup
2008-07-10 21:25:00 +00:00
category: ! os:hpux
2008-07-08 20:54:33 +00:00
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . UTF - 8 !
stdin:
2008-12-13 17:02:18 +00:00
if [ [ $- = * U * ] ] ; then
2009-10-02 18:08:37 +00:00
echo is set
2008-07-08 20:54:33 +00:00
else
2009-10-02 18:08:37 +00:00
echo is not set
2008-07-08 20:54:33 +00:00
fi
expected - stdout:
is not set
- - -
name: utf8opt - 1 b
description:
2008-12-04 18:11:08 +00:00
Check that the utf8 - mode flag is not set at non - interactive startup
2008-07-10 21:20:22 +00:00
category: os:hpux
2008-05-04 01:38:04 +00:00
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . utf8 !
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
stdin:
2008-12-13 17:02:18 +00:00
if [ [ $- = * U * ] ] ; then
2009-10-02 18:08:37 +00:00
echo is set
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
else
2009-10-02 18:08:37 +00:00
echo is not set
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
fi
expected - stdout:
is not set
- - -
2008-06-02 20:44:07 +00:00
name: utf8opt - 2 a
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
description:
2009-08-01 21:57:52 +00:00
Check that the utf8 - mode flag is set at interactive startup .
- DMKSH_ASSUME_UTF8 = 0 = > expected failure , please ignore
- DMKSH_ASSUME_UTF8 = 1 = > not expected , please investigate
- UMKSH_ASSUME_UTF8 = > not expected , but if your OS is old ,
try passing HAVE_SETLOCALE_CTYPE = 0 to Build . sh
2011-08-27 17:30:07 +00:00
need - pass: no
2012-01-03 01:40:15 +00:00
category: ! os:hpux , ! os:msys
2011-03-28 21:58:06 +00:00
need - ctty: yes
2008-06-02 20:44:07 +00:00
arguments: ! - i !
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . UTF - 8 !
stdin:
2008-12-13 17:02:18 +00:00
if [ [ $- = * U * ] ] ; then
2009-10-02 18:08:37 +00:00
echo is set
2008-06-02 20:44:07 +00:00
else
2009-10-02 18:08:37 +00:00
echo is not set
2008-06-02 20:44:07 +00:00
fi
expected - stdout:
is set
expected - stderr - pattern:
/(# )*/
- - -
name: utf8opt - 2 b
description:
2008-12-04 18:11:08 +00:00
Check that the utf8 - mode flag is set at interactive startup
2009-06-07 22:43:46 +00:00
Expected failure if - DMKSH_ASSUME_UTF8 = 0
2008-07-10 21:25:00 +00:00
category: os:hpux
2011-03-28 21:58:06 +00:00
need - ctty: yes
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
arguments: ! - i !
2008-05-04 01:38:04 +00:00
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . utf8 !
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
stdin:
2008-12-13 17:02:18 +00:00
if [ [ $- = * U * ] ] ; then
2009-10-02 18:08:37 +00:00
echo is set
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
else
2009-10-02 18:08:37 +00:00
echo is not set
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
fi
expected - stdout:
is set
2008-05-10 03:16:07 +00:00
expected - stderr - pattern:
/(# )*/
• more unsigned → unsigned int
• more int → bool
• more regression tests: check if the utf8-hack flag is really disabled
at non-interactive startup, enabled at interactive startup, if the
current locale is a UTF-8 one
• make the mksh-local multibyte handling functions globally accessible,
change their names, syntax and semantics a little (XXX more work needed)
• optimise
• utf_wctomb: src → dst, as we’re writing to that char array (pasto?)
• edit.c:x_e_getmbc(): if the second byte of a 2- or 3-byte multibyte
sequence is invalid utf-8, ungetc it (not possible for the 3rd byte yet)
• edit.c:x_zotc3(): easier (and faster) handling of UTF-8
• implement, document and test for base-1 numbers: they just get the
ASCII (8-bit) or Unicode (UTF-8) value of the octet(s) after the ‘1#’,
or do the same as print \x## or \u#### (depending on the utf8-hack flag),
plus support the PUA assignment of EF80‥EFFF for the MirBSD encoding “hack”
(print doesn’t, as it has \x## and \u#### to distinguish, but we cannot use
base-0 numbers which I had planned to use for raw octets first, as they are
used internally): http://thread.gmane.org/gmane.os.miros.general/7938
• as an application example, add a hexdumper to the regression tests ☺
2008-04-19 22:15:06 +00:00
- - -
2011-07-07 21:02:39 +00:00
name: utf8opt - 3 a
2009-11-28 15:38:30 +00:00
description:
Ensure ± U on the command line is honoured
2011-07-07 21:02:39 +00:00
( these two tests may pass falsely depending on CPPFLAGS )
2009-11-28 15:38:30 +00:00
stdin:
export i = 0
code = 'if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
let i + + ; "$__progname" - U - c "$code"
let i + + ; "$__progname" + U - c "$code"
2011-07-07 21:02:39 +00:00
echo $( ( + + i ) ) done
expected - stdout:
1 on
2 off
3 done
- - -
name: utf8opt - 3 b
description:
Ensure ± U on the command line is honoured , interactive shells
need - ctty: yes
stdin:
export i = 0
code = 'if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
2009-11-28 15:38:30 +00:00
let i + + ; "$__progname" - U - ic "$code"
let i + + ; "$__progname" + U - ic "$code"
echo $( ( + + i ) ) done
expected - stdout:
1 on
2 off
2011-07-07 21:02:39 +00:00
3 done
2009-11-28 15:38:30 +00:00
- - -
2007-06-15 21:55:20 +00:00
name: aliases - 1
description:
Check if built - in shell aliases are okay
stdin:
alias
typeset - f
expected - stdout:
2015-03-14 05:23:18 +00:00
autoload = '\typeset -fu'
functions = '\typeset -f'
2015-03-08 22:54:36 +00:00
hash = '\builtin alias -t'
history = '\builtin fc -l'
2015-03-14 05:23:18 +00:00
integer = '\typeset -i'
local = '\typeset'
2015-03-08 22:54:36 +00:00
login = '\exec login'
2015-03-14 05:23:18 +00:00
nameref = '\typeset -n'
2007-06-15 21:55:20 +00:00
nohup = 'nohup '
2015-03-08 22:54:36 +00:00
r = '\builtin fc -e -'
2015-07-10 19:36:38 +00:00
type = '\builtin whence -v'
- - -
2008-02-25 00:58:26 +00:00
name: aliases - 2 b
description:
2009-10-02 18:08:37 +00:00
Check if “ set - o sh ” does not influence built - in aliases
arguments: ! - o ! sh !
2008-02-25 00:58:26 +00:00
stdin:
alias
typeset - f
expected - stdout:
2015-03-14 05:23:18 +00:00
autoload = '\typeset -fu'
functions = '\typeset -f'
2015-03-08 22:54:36 +00:00
hash = '\builtin alias -t'
history = '\builtin fc -l'
2015-03-14 05:23:18 +00:00
integer = '\typeset -i'
local = '\typeset'
2015-03-08 22:54:36 +00:00
login = '\exec login'
2015-03-14 05:23:18 +00:00
nameref = '\typeset -n'
2008-02-25 00:58:26 +00:00
nohup = 'nohup '
2015-03-08 22:54:36 +00:00
r = '\builtin fc -e -'
type = '\builtin whence -v'
2008-02-25 00:58:26 +00:00
- - -
name: aliases - 3 b
description:
Check if running as sh does not influence built - in aliases
2015-07-10 19:36:38 +00:00
stdin:
cp "$__progname" sh
. / sh - c 'alias; typeset -f'
rm - f sh
expected - stdout:
autoload = '\typeset -fu'
functions = '\typeset -f'
hash = '\builtin alias -t'
history = '\builtin fc -l'
integer = '\typeset -i'
local = '\typeset'
login = '\exec login'
nameref = '\typeset -n'
nohup = 'nohup '
r = '\builtin fc -e -'
type = '\builtin whence -v'
- - -
2012-06-28 20:05:11 +00:00
name: aliases - cmdline
description:
Check that aliases work from the command line ( Debian #517009)
Note that due to the nature of the lexing process , defining
aliases in COMSUBs then immediately using them , and things
like 'alias foo=bar && foo' , still fail .
stdin:
"$__progname" - c $ ' alias a = "echo OK" \ na '
expected - stdout:
OK
- - -
2009-07-06 15:06:25 +00:00
name: aliases - funcdef - 1
description:
Check if POSIX functions take precedences over aliases
2015-03-20 23:37:55 +00:00
stdin:
alias foo = 'echo makro'
foo ( ) {
echo funktion
}
foo
expected - stdout:
makro
- - -
2009-07-06 15:06:25 +00:00
name: aliases - funcdef - 2
description:
Check if POSIX functions take precedences over aliases
2015-03-20 23:37:55 +00:00
stdin:
alias foo = 'echo makro'
foo ( ) {
echo funktion
}
foo
expected - stdout:
makro
- - -
2009-07-06 15:06:25 +00:00
name: aliases - funcdef - 3
description:
Check if aliases take precedences over Korn functions
stdin:
alias foo = 'echo makro'
function foo {
echo funktion
}
foo
expected - stdout:
makro
- - -
2011-05-07 00:02:26 +00:00
name: aliases - funcdef - 4
description:
Functions should only take over if actually being defined
stdin:
alias local
2011-05-07 00:51:12 +00:00
: || local ( ) { : ; }
2011-05-07 00:02:26 +00:00
alias local
expected - stdout:
2015-03-14 05:23:18 +00:00
local = '\typeset'
local = '\typeset'
2011-05-07 00:02:26 +00:00
- - -
2007-06-22 23:34:42 +00:00
name: arrays - 1
description:
Check if Korn Shell arrays work as expected
stdin:
v = "c d"
set - A foo - - a \ $ v "$v" '$v' b
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
expected - stdout:
5 | a | $ v | c d | $ v | b |
- - -
2011-06-04 16:11:20 +00:00
name: arrays - 2 a
2007-06-22 23:34:42 +00:00
description:
Check if bash - style arrays work as expected
stdin:
v = "c d"
foo = ( a \ $ v "$v" '$v' b )
echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
expected - stdout:
5 | a | $ v | c d | $ v | b |
- - -
2011-06-04 16:11:20 +00:00
name: arrays - 2 b
description:
Check if bash - style arrays work as expected , with newlines
stdin:
2012-03-31 18:26:53 +00:00
print '#!' "$__progname" '\nfor x in "$@"; do print -nr -- "$x|"; done' > pfp
chmod + x pfp
2011-06-04 16:11:20 +00:00
test - n "$ZSH_VERSION" && setopt KSH_ARRAYS
v = "e f"
foo = ( a
bc
d \ $ v "$v" '$v' g
)
2012-03-31 18:26:53 +00:00
. / pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}" ; echo
2011-06-04 16:11:20 +00:00
foo = ( a \
bc
d \ $ v "$v" '$v' g
)
2012-03-31 18:26:53 +00:00
. / pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}" ; echo
2011-06-04 16:11:20 +00:00
foo = ( a \
bc \ \
d \ $ v "$v" '$v'
g )
2012-03-31 18:26:53 +00:00
. / pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}" ; echo
2011-06-04 16:11:20 +00:00
expected - stdout:
7 | a | bc | d | $ v | e f | $ v | g |
7 | a | bc | d | $ v | e f | $ v | g |
6 | abc \ | d | $ v | e f | $ v | g ||
- - -
2007-10-18 20:32:33 +00:00
name: arrays - 3
description:
Check if array bounds are uint32_t
stdin:
set - A foo a b c
foo [ 4097 ] = d
foo [ 2147483637 ] = e
2009-10-02 18:08:37 +00:00
echo $ { foo [ * ] }
2007-10-18 20:32:33 +00:00
foo [ - 1 ] = f
2009-10-02 18:08:37 +00:00
echo $ { foo [ 4294967295 ] } g $ { foo [ * ] }
2007-10-18 20:32:33 +00:00
expected - stdout:
a b c d e
f g a b c d e f
- - -
2009-08-28 22:46:21 +00:00
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]}|"
2014-06-09 11:13:19 +00:00
# we don't want this at all:
# 5|a|$v|c d||$v|b|
2014-05-29 21:30:45 +00:00
set - A arr "[5]=meh"
echo "<${arr[0]}><${arr[5]}>"
expected - stdout:
2014-06-09 11:13:19 +00:00
5 | [ 1 ] = $ v | [ 2 ] = c d | [ 4 ] = $ v | [ 0 ] = a | [ 5 ] = b ||
2014-05-29 21:30:45 +00:00
<[5]=meh> < >
- - -
2009-08-28 22:46:21 +00:00
name: arrays - 5
description:
Check if bash - style arrays with specified indices work as expected
2014-06-09 11:13:19 +00:00
( taken out temporarily to fix arrays - 4 ; see also arrays - 9 a comment )
category: disabled
2009-08-28 22:46:21 +00:00
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]}|"
2009-12-01 19:15:35 +00:00
x = ( [ 128 ] = foo bar baz )
echo k = $ { ! x [ * ] } .
echo v = $ { x [ * ] } .
2014-06-09 11:13:19 +00:00
# Check that we do not break this by globbing
2014-05-29 21:30:45 +00:00
: > b = blah
bleh = 5
typeset - a arr
arr += ( [ bleh ] = blah )
echo "<${arr[0]}><${arr[5]}>"
expected - stdout:
2014-06-09 11:13:19 +00:00
5 | a | $ v | c d || $ v | b |
k = 128 129 130 .
v = foo bar baz .
2014-05-29 21:30:45 +00:00
< > <blah>
- - -
2009-08-28 22:46:21 +00:00
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
- - -
2009-09-06 17:42:15 +00:00
name: arrays - 7
description:
Check if we can get the array keys ( indices ) for indexed arrays ,
Korn shell style , in some corner cases
stdin:
2009-10-02 18:08:37 +00:00
echo ! arz: $ { ! arz }
echo ! arz [ 0 ] : $ { ! arz [ 0 ] }
echo ! arz [ 1 ] : $ { ! arz [ 1 ] }
2009-09-06 17:42:15 +00:00
arz = foo
2009-10-02 18:08:37 +00:00
echo ! arz: $ { ! arz }
echo ! arz [ 0 ] : $ { ! arz [ 0 ] }
echo ! arz [ 1 ] : $ { ! arz [ 1 ] }
2009-09-06 17:42:15 +00:00
unset arz
2009-10-02 18:08:37 +00:00
echo ! arz: $ { ! arz }
echo ! arz [ 0 ] : $ { ! arz [ 0 ] }
echo ! arz [ 1 ] : $ { ! arz [ 1 ] }
2009-09-06 17:42:15 +00:00
expected - stdout:
! arz: arz
2014-05-27 13:00:31 +00:00
! arz [ 0 ] : arz [ 0 ]
! arz [ 1 ] : arz [ 1 ]
! arz: arz
! arz [ 0 ] : arz [ 0 ]
! arz [ 1 ] : arz [ 1 ]
! arz: arz
! arz [ 0 ] : arz [ 0 ]
! arz [ 1 ] : arz [ 1 ]
2009-09-06 17:42:15 +00:00
- - -
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
name: arrays - 8
description:
Check some behavioural rules for arrays .
stdin:
fna ( ) {
set - A aa 9
}
fnb ( ) {
typeset ab
set - A ab 9
}
fnc ( ) {
typeset ac
set - A ac 91
unset ac
set - A ac 92
}
fnd ( ) {
set + A ad 9
}
fne ( ) {
unset ae
set + A ae 9
}
fnf ( ) {
unset af [ 0 ]
set + A af 9
}
fng ( ) {
unset ag [ * ]
set + A ag 9
}
set - A aa 1 2
set - A ab 1 2
set - A ac 1 2
set - A ad 1 2
set - A ae 1 2
set - A af 1 2
set - A ag 1 2
2010-01-25 14:25:16 +00:00
set - A ah 1 2
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
typeset - Z3 aa ab ac ad ae af ag
print 1 a $ { aa [ * ] } .
print 1 b $ { ab [ * ] } .
print 1 c $ { ac [ * ] } .
print 1 d $ { ad [ * ] } .
print 1 e $ { ae [ * ] } .
print 1 f $ { af [ * ] } .
print 1 g $ { ag [ * ] } .
2010-01-25 14:25:16 +00:00
print 1 h $ { ah [ * ] } .
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
fna
fnb
fnc
fnd
fne
fnf
fng
2010-01-25 14:25:16 +00:00
typeset - Z5 ah [ * ]
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
print 2 a $ { aa [ * ] } .
print 2 b $ { ab [ * ] } .
print 2 c $ { ac [ * ] } .
print 2 d $ { ad [ * ] } .
print 2 e $ { ae [ * ] } .
print 2 f $ { af [ * ] } .
print 2 g $ { ag [ * ] } .
2010-01-25 14:25:16 +00:00
print 2 h $ { ah [ * ] } .
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
expected - stdout:
1 a 001 002 .
1 b 001 002 .
1 c 001 002 .
1 d 001 002 .
1 e 001 002 .
1 f 001 002 .
1 g 001 002 .
2010-01-25 14:25:16 +00:00
1 h 1 2 .
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
2 a 9 .
2 b 001 002 .
2 c 92 .
2 d 00 9 002 .
2 e 9 .
2 f 9 002 .
2 g 00 9 .
2010-01-25 14:25:16 +00:00
2 h 00001 00002 .
Add “unset foo[*]” mksh extension, which allows to unset the *contents*
of foo[0] (but not its attributes), and the rest of the array, so that
later “set +A foo bar” will set foo[0]=bar but retain the attributes.
This is important, because, in the future, arrays will have different
attributes per element, instead of all the same (which, actually, is
not entirely true right now either, since “unset foo[0]” will not mo-
dify the attributes of a foo[1] existing at that point in time), where
foo[$newkey] will inherit from foo[0], but typeset foo will only affect
foo[0] no longer foo[*] in the future. (The rules about typeset=local
will still apply, as they affect creation of variables in a scope.)
2010-01-25 14:11:29 +00:00
- - -
2011-05-07 02:02:47 +00:00
name: arrays - 9 a
2011-05-04 23:16:05 +00:00
description:
2011-05-07 02:02:47 +00:00
Check that we can concatenate arrays
stdin:
unset foo ; foo = ( bar ) ; foo += ( baz ) ; echo 1 $ { ! foo [ * ] } : $ { foo [ * ] } .
unset foo ; foo = ( foo bar ) ; foo += ( baz ) ; echo 2 $ { ! foo [ * ] } : $ { foo [ * ] } .
2014-06-09 11:13:19 +00:00
# unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
2011-05-07 02:02:47 +00:00
expected - stdout:
1 0 1 : bar baz .
2 0 1 2 : foo bar baz .
2014-06-09 11:13:19 +00:00
# 3 0 2 3 5 : bar foo baz quux .
2011-05-07 02:02:47 +00:00
- - -
name: arrays - 9 b
description:
Check that we can concatenate parameters too
2011-05-04 23:16:05 +00:00
stdin:
unset foo ; foo = bar ; foo += baz ; echo 1 $ foo .
unset foo ; typeset - i16 foo = 10 ; foo += 20 ; echo 2 $ foo .
expected - stdout:
1 barbaz .
2 16 #a20 .
- - -
2011-11-25 23:33:42 +00:00
name: arrassign - basic
description:
Check basic whitespace conserving properties of wdarrassign
stdin:
a = ( $ ( echo a b ) )
b = ( $ ( echo "a b" ) )
c = ( "$(echo " a b ")" )
d = ( "$(echo a b)" )
a += ( $ ( echo c d ) )
b += ( $ ( echo "c d" ) )
c += ( "$(echo " c d ")" )
d += ( "$(echo c d)" )
echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
expected - stdout:
. a:a . b . c . d:
. b:a . b . c . d:
. c:a b . c d .. :
. d:a b . c d .. :
- - -
name: arrassign - fnc - none
description:
Check locality of array access inside a function
stdin:
function fn {
x += ( f )
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
if [ [ - n $ BASH_VERSION ] ] ; then
y = ( )
else
set - A y
fi
y += ( f )
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
x = ( m m )
y = ( m m )
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
expected - stdout:
. f0:m . m .. :
. fn:m . m . f . :
. f1:m . m . f . :
. fn:m . m . f . f:
. f2:m . m . f . f:
. rf0:m . m .. :
. rfn:f ... :
. rf1:f ... :
. rfn:f ... :
. rf2:f ... :
- - -
name: arrassign - fnc - local
description:
Check locality of array access inside a function
with the bash /mksh/ ksh93 local / typeset keyword
( note: ksh93 has no local ; typeset works only in FKSH )
stdin:
function fn {
typeset x
x += ( f )
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
if [ [ - n $ BASH_VERSION ] ] ; then
y = ( )
else
set - A y
fi
typeset y
y += ( f )
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
function fnr {
typeset z
if [ [ - n $ BASH_VERSION ] ] ; then
z = ( )
else
set - A z
fi
z += ( f )
echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
}
x = ( m m )
y = ( m m )
z = ( m m )
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
expected - stdout:
. f0:m . m .. :
. fn:f ... :
. f1:m . m .. :
. fn:f ... :
. f2:m . m .. :
. rf0:m . m .. :
. rfn:f ... :
. rf1: ... :
. rfn:f ... :
. rf2: ... :
. f0r:m . m .. :
. fnr:f ... :
. f1r:m . m .. :
. fnr:f ... :
. f2r:m . m .. :
- - -
name: arrassign - fnc - global
description:
Check locality of array access inside a function
with the mksh - specific global keyword
stdin:
function fn {
global x
x += ( f )
echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
}
function rfn {
set - A y
global y
y += ( f )
echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
}
function fnr {
global z
set - A z
z += ( f )
echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
}
x = ( m m )
y = ( m m )
z = ( m m )
echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
fn
echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
rfn
echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
fnr
echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
expected - stdout:
. f0:m . m .. :
. fn:m . m . f . :
. f1:m . m . f . :
. fn:m . m . f . f:
. f2:m . m . f . f:
. rf0:m . m .. :
. rfn:f ... :
. rf1:f ... :
. rfn:f ... :
. rf2:f ... :
. f0r:m . m .. :
. fnr:f ... :
. f1r:f ... :
. fnr:f ... :
. f2r:f ... :
- - -
name: strassign - fnc - none
description:
Check locality of string access inside a function
stdin:
function fn {
x += f
echo ".fn:$x:"
}
function rfn {
y =
y += f
echo ".rfn:$y:"
}
x = m
y = m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
expected - stdout:
. f0:m:
. fn:mf:
. f1:mf:
. fn:mff:
. f2:mff:
. rf0:m:
. rfn:f:
. rf1:f:
. rfn:f:
. rf2:f:
- - -
name: strassign - fnc - local
description:
Check locality of string access inside a function
with the bash /mksh/ ksh93 local / typeset keyword
( note: ksh93 has no local ; typeset works only in FKSH )
stdin:
function fn {
typeset x
x += f
echo ".fn:$x:"
}
function rfn {
y =
typeset y
y += f
echo ".rfn:$y:"
}
function fnr {
typeset z
z =
z += f
echo ".fnr:$z:"
}
x = m
y = m
z = m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
echo ".f0r:$z:"
fnr
echo ".f1r:$z:"
fnr
echo ".f2r:$z:"
expected - stdout:
. f0:m:
. fn:f:
. f1:m:
. fn:f:
. f2:m:
. rf0:m:
. rfn:f:
. rf1::
. rfn:f:
. rf2::
. f0r:m:
. fnr:f:
. f1r:m:
. fnr:f:
. f2r:m:
- - -
name: strassign - fnc - global
description:
Check locality of string access inside a function
with the mksh - specific global keyword
stdin:
function fn {
global x
x += f
echo ".fn:$x:"
}
function rfn {
y =
global y
y += f
echo ".rfn:$y:"
}
function fnr {
global z
z =
z += f
echo ".fnr:$z:"
}
x = m
y = m
z = m
echo ".f0:$x:"
fn
echo ".f1:$x:"
fn
echo ".f2:$x:"
echo ".rf0:$y:"
rfn
echo ".rf1:$y:"
rfn
echo ".rf2:$y:"
echo ".f0r:$z:"
fnr
echo ".f1r:$z:"
fnr
echo ".f2r:$z:"
expected - stdout:
. f0:m:
. fn:mf:
. f1:mf:
. fn:mff:
. f2:mff:
. rf0:m:
. rfn:f:
. rf1:f:
. rfn:f:
. rf2:f:
. f0r:m:
. fnr:f:
. f1r:f:
. fnr:f:
. f2r:f:
- - -
2014-10-10 22:10:19 +00:00
name: unset - fnc - local - ksh
description:
Check that “ unset ” removes a previous “ local ”
( ksh93 syntax compatible version ) ; apparently ,
there are shells which fail this ?
stdin:
function f {
echo f0: $ x
typeset x
echo f1: $ x
x = fa
echo f2: $ x
unset x
echo f3: $ x
x = fb
echo f4: $ x
}
x = o
echo before: $ x
f
echo after: $ x
expected - stdout:
before: o
f0: o
f1:
f2: fa
f3: o
f4: fb
after: fb
- - -
name: unset - fnc - local - sh
description:
Check that “ unset ” removes a previous “ local ”
( Debian Policy § 10.4 sh version ) ; apparently ,
there are shells which fail this ?
stdin:
f ( ) {
echo f0: $ x
local x
echo f1: $ x
x = fa
echo f2: $ x
unset x
echo f3: $ x
x = fb
echo f4: $ x
}
x = o
echo before: $ x
f
echo after: $ x
expected - stdout:
before: o
f0: o
f1:
f2: fa
f3: o
f4: fb
after: fb
- - -
2007-06-27 23:12:59 +00:00
name: varexpand - substr - 1
description:
Check if bash - style substring expansion works
when using positive numerics
stdin:
x = abcdefghi
typeset - i y = 123456789
typeset - i 16 z = 123456789 # 16#75bcd15
2009-10-02 18:08:37 +00:00
echo a t $ { x:2:2 } $ { y:2:3 } $ { z:2:3 } a
echo b $ { x:: 3 } $ { y:: 3 } $ { z:: 3 } b
echo c $ { x:2: } $ { y:2: } $ { z:2: } c
echo d $ { x:2 } $ { y:2 } $ { z:2 } d
echo e $ { x:2:6 } $ { y:2:6 } $ { z:2:7 } e
echo f $ { x:2:7 } $ { y:2:7 } $ { z:2:8 } f
echo g $ { x:2:8 } $ { y:2:8 } $ { z:2:9 } g
2007-06-27 23:12:59 +00:00
expected - stdout:
2007-07-06 01:30:32 +00:00
a tcd 345 #75 a
2007-06-27 23:12:59 +00:00
b abc 123 16 # b
2007-07-06 01:37:39 +00:00
c c
2007-06-27 23:12:59 +00:00
d cdefghi 3456789 #75bcd15 d
e cdefgh 345678 #75bcd1 e
f cdefghi 3456789 #75bcd15 f
g cdefghi 3456789 #75bcd15 g
- - -
name: varexpand - substr - 2
description:
Check if bash - style substring expansion works
when using negative numerics or expressions
stdin:
x = abcdefghi
typeset - i y = 123456789
typeset - i 16 z = 123456789 # 16#75bcd15
n = 2
2009-10-02 18:08:37 +00:00
echo a $ { x: $ n:3 } $ { y: $ n:3 } $ { z: $ n:3 } a
echo b $ { x: ( n ) : 3 } $ { y: ( n ) : 3 } $ { z: ( n ) : 3 } b
echo c $ { x: ( - 2 ) : 1 } $ { y: ( - 2 ) : 1 } $ { z: ( - 2 ) : 1 } c
echo d t $ { x: n:2 } $ { y: n:3 } $ { z: n:3 } d
2007-06-27 23:12:59 +00:00
expected - stdout:
a cde 345 #75 a
b cde 345 #75 b
c h 8 1 c
2007-07-06 02:22:57 +00:00
d tcd 345 #75 d
- - -
name: varexpand - substr - 3
description:
Check that some things that work in bash fail .
2016-01-14 23:19:12 +00:00
This is by design . Oh and vice versa , nowadays .
2007-07-06 02:22:57 +00:00
stdin:
export x = abcdefghi n = 2
2009-07-19 11:14:28 +00:00
"$__progname" - c 'echo v${x:(n)}x'
"$__progname" - c 'echo w${x: n}x'
"$__progname" - c 'echo x${x:n}x'
"$__progname" - c 'echo y${x:}x'
"$__progname" - c 'echo z${x}x'
2016-01-14 23:19:12 +00:00
# next fails only in bash
2009-07-19 11:14:28 +00:00
"$__progname" - c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' > /dev/ null 2 > & 1 ; echo $?
2007-07-06 02:22:57 +00:00
expected - stdout:
vcdefghix
wcdefghix
zabcdefghix
2016-01-14 23:19:12 +00:00
0
2007-07-06 02:22:57 +00:00
expected - stderr - pattern:
/x:n.*bad substitution.*\n.*bad substitution/
2007-06-27 23:12:59 +00:00
- - -
2007-07-23 14:10:48 +00:00
name: varexpand - substr - 4
description:
Check corner cases for substring expansion
stdin:
x = abcdefghi
integer y = 2
2009-10-02 18:08:37 +00:00
echo a $ { x: ( y == 1 ? 2 : 3 ) : 4 } a
2007-07-23 14:10:48 +00:00
expected - stdout:
a defg a
- - -
2009-05-16 15:53:02 +00:00
name: varexpand - substr - 5 A
description:
Check that substring expansions work on characters
stdin:
set + U
x = mäh
2009-10-02 18:08:37 +00:00
echo a $ { x:: 1 } $ { x: - 1 } a
echo b $ { x:: 3 } $ { x: - 3 } b
echo c $ { x:1:2 } $ { x: - 3 : 2 } c
echo d $ { #x} d
2009-05-16 15:53:02 +00:00
expected - stdout:
a m h a
b mä äh b
c ä ä c
d 4 d
- - -
name: varexpand - substr - 5 W
description:
Check that substring expansions work on characters
stdin:
set - U
x = mäh
2009-10-02 18:08:37 +00:00
echo a $ { x:: 1 } $ { x: - 1 } a
echo b $ { x:: 2 } $ { x: - 2 } b
echo c $ { x:1:1 } $ { x: - 2 : 1 } c
echo d $ { #x} d
2009-05-16 15:53:02 +00:00
expected - stdout:
a m h a
b mä äh b
c ä ä c
d 3 d
- - -
2009-08-28 21:35:43 +00:00
name: varexpand - substr - 6
description:
Check that string substitution works correctly
stdin:
foo = 1
bar = 2
baz = qwertyuiop
echo a $ { baz: foo: bar }
echo b $ { baz: foo: $ bar }
echo c $ { baz: $ foo: bar }
echo d $ { baz: $ foo: $ bar }
expected - stdout:
a we
b we
c we
d we
- - -
2011-01-21 22:25:34 +00:00
name: varexpand - special - hash
description:
Check special $ { var @ x } expansion for x = hash
stdin:
typeset - i8 foo = 10
bar = baz
2011-07-06 22:22:02 +00:00
unset baz
print $ { foo @# } $ { bar @# } $ { baz @# } .
2011-01-21 22:25:34 +00:00
expected - stdout:
2014-01-11 18:09:43 +00:00
9 B15FBFB CFBDD32B 00000000 .
2011-01-21 22:25:34 +00:00
- - -
2012-07-20 23:22:13 +00:00
name: varexpand - special - quote
description:
Check special $ { var @ Q } expansion for quoted strings
stdin:
set + U
i = x
j = a \ b
k = $ ' c
d \ xA0 '' e € f '
print - r - - "<i=$i j=$j k=$k>"
s = "u=${i@Q} v=${j@Q} w=${k@Q}"
print - r - - "s=\"$s\""
eval "$s"
typeset - p u v w
expected - stdout:
< i = x j = a b k = c
d <EFBFBD> e € f >
s = "u=x v='a b' w=$'c\nd\240e\u20ACf'"
typeset u = x
typeset v = 'a b'
typeset w = $ ' c \ nd \ 240 e \ u20ACf '
- - -
2009-11-21 22:29:12 +00:00
name: varexpand - null - 1
description:
Ensure empty strings expand emptily
stdin:
2015-02-19 22:26:50 +00:00
print s $ { a } . $ { b } S
print t $ { a #?} . ${b%?} T
print r $ { a = } . $ { b /c/ d } R
print q
print s "${a}" . "${b}" S
print t "${a#?}" . "${b%?}" T
print r "${a=}" . "${b/c/d}" R
expected - stdout:
s . S
t . T
r . R
q
s . S
t . T
r . R
2009-11-21 22:29:12 +00:00
- - -
2010-04-09 19:16:31 +00:00
name: varexpand - null - 2
description:
Ensure empty strings , when quoted , are expanded as empty strings
stdin:
2012-03-31 18:26:53 +00:00
print '#!' "$__progname" '\nfor x in "$@"; do print -nr -- "<$x> "; done' > pfs
chmod + x pfs
. /pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c / d } "
2010-04-09 19:16:31 +00:00
echo .
expected - stdout:
<1> < > <2> < > <+> < > <3> < > <+> < > .
- - -
2014-10-03 17:32:12 +00:00
name: varexpand - null - 3
description:
Ensure concatenating behaviour matches other shells
stdin:
2015-01-25 15:23:43 +00:00
showargs ( ) { for s_arg in "$@" ; do echo - n "<$s_arg> " ; done ; echo . ; }
2015-07-06 17:48:37 +00:00
showargs 0 "" $@
2014-11-14 20:21:29 +00:00
x = ; showargs 1 "$x" $@
2014-10-24 12:13:52 +00:00
set A ; showargs 2 "${@:+}"
2015-02-20 07:14:30 +00:00
n ( ) { echo "$#" ; }
unset e
set - - a b
n "" "$@"
n "$@"
n "$@" ""
n "$e" "$@"
n "$@"
n "$@" "$e"
set - -
n "" "$@"
n "$@"
n "$@" ""
n "$e" "$@"
n "$@"
n "$@" "$e"
2014-10-03 17:32:12 +00:00
expected - stdout:
2015-07-06 17:48:37 +00:00
<0> < > .
2015-01-25 15:23:43 +00:00
<1> < > .
<2> < > .
2015-02-20 07:14:30 +00:00
2
2
2
2
2
2
1
0
1
1
0
1
2014-10-03 17:32:12 +00:00
- - -
2015-10-24 19:46:10 +00:00
name: varexpand - funny - chars
description:
Check some characters
XXX \ uEF80 is asymmetric , possibly buggy so we don ’ t check this
stdin:
x = $' <\x00> ' ; typeset - p x
x = $' <\x01> ' ; typeset - p x
x = $' <\u0000> ' ; typeset - p x
x = $' <\u0001> ' ; typeset - p x
expected - stdout:
typeset x = '<'
typeset x = $' <\001> '
typeset x = '<'
typeset x = $' <\001> '
- - -
2008-02-24 15:48:43 +00:00
name: print - funny - chars
description:
Check print builtin ' s capability to output designated characters
stdin:
print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
2015-10-24 19:46:10 +00:00
print '<\x00>'
print '<\x01>'
print '<\u0000>'
print '<\u0001>'
2008-02-24 15:48:43 +00:00
expected - stdout:
<d<> <64> Û€Û@>
2015-10-24 19:46:10 +00:00
<