2009-08-08 15:08:53 +02:00
# $MirOS: src/bin/mksh/check.t,v 1.299 2009/08/08 13:08:48 tg Exp $
2005-05-23 05:06:10 +02:00
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
#-
2009-05-16 20:40:09 +02:00
# Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009
2009-05-16 18:59:42 +02:00
# Thorsten Glaser <tg@mirbsd.org>
#
# Provided that these terms and disclaimer and all copyright notices
# are retained or reproduced in an accompanying document, permission
2009-05-16 20:40:09 +02:00
# is granted to deal in this work without restriction, including un‐
2009-05-16 18:59:42 +02:00
# limited rights to use, publicly perform, distribute, sell, modify,
# merge, give away, or sublicence.
#
2009-05-16 20:40:09 +02:00
# This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
2009-05-16 18:59:42 +02: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 20:40:09 +02:00
# of said person’ s immediate fault when using the work as intended.
2009-05-16 18:59:42 +02:00
#-
2005-06-08 23:51:22 +02:00
# You may also want to test IFS with the script at
# http://www.research.att.com/~gsf/public/ifs.sh
2005-05-23 05:06:10 +02:00
2006-11-12 11:44:42 +01:00
expected - stdout:
2009-08-08 15:08:53 +02:00
@ ( # ) MIRBSD KSH R39 2009 /08/ 08
2006-11-12 11:44:42 +01:00
description:
Check version of shell .
stdin:
echo $ KSH_VERSION
name: KSH_VERSION
- - -
2008-03-23 21:43:51 +01:00
name: selftest - 1
description:
Regression test self - testing
stdin:
print $ { foo: - baz }
expected - stdout:
baz
- - -
name: selftest - 2
description:
Regression test self - testing
env - setup: ! foo = bar !
stdin:
print $ { foo: - baz }
expected - stdout:
bar
- - -
name: selftest - 3
description:
Regression test self - testing
env - setup: ! ENV = fnord !
stdin:
print "<$ENV>"
expected - stdout:
<fnord>
- - -
2008-04-01 18:26:42 +02:00
name: selftest - env
description:
Just output the environment variables set ( always fails )
category: disabled
stdin:
set
- - -
2005-05-23 05:06:10 +02: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 13:48:16 +01:00
name: alias - 9
description:
Check that recursion is detected / avoided in aliases .
2008-12-08 14:57:35 +01:00
This check fails for slow machines or Cygwin , raise
the time - limit clause ( e . g . to 7 ) if this occurs .
2008-12-02 14:19:28 +01:00
time - limit: 3
2008-12-02 13:48:16 +01:00
stdin:
echo - n > tf
alias ls = ls
ls
echo $ ( ls )
exit 0
expected - stdout:
tf
tf
- - -
2005-05-23 05:06:10 +02: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
- - -
name: arith - ternary - prec - 1
description:
Check precidance of ternary operator vs assignment
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:
Check precidance of ternary operator vs assignment
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
- - -
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
- - -
2008-12-17 20:39:23 +01:00
name: arith - unsigned - 1
description:
Check if unsigned arithmetics work
stdin:
# signed vs unsigned
print x1 $( ( - 1 ) ) $( ( #-1))
# calculating
typeset - i vs
typeset - Ui vu
vs = 4123456789 ; vu = 4123456789
print x2 $ vs $ vu
( ( vs % = 2147483647 ) )
( ( vu % = 2147483647 ) )
print x3 $ vs $ vu
vs = 4123456789 ; vu = 4123456789
( ( # vs %= 2147483647 ))
( ( # vu %= 2147483647 ))
print x4 $ vs $ vu
# make sure the calculation does not change unsigned flag
vs = 4123456789 ; vu = 4123456789
print x5 $ vs $ vu
# short form
print x6 $( ( # vs % 2147483647)) $((# vu % 2147483647))
# array refs
set - A va
va [ 1975973142 ] = right
va [ 4123456789 ] = wrong
print x7 $ { va [ #4123456789%2147483647]}
expected - stdout:
x1 - 1 4294967295
x2 - 171510507 4123456789
x3 - 171510507 4123456789
x4 1975973142 1975973142
x5 - 171510507 4123456789
x6 1975973142 1975973142
x7 right
- - -
2009-03-14 19:12:55 +01:00
name: arith - limit32 - 1
description:
Check if arithmetics are 32 bit
stdin:
# signed vs unsigned
print x1 $( ( - 1 ) ) $( ( #-1))
# calculating
typeset - i vs
typeset - Ui vu
vs = 2147483647 ; vu = 2147483647
print x2 $ vs $ vu
let vs + + vu + +
print x3 $ vs $ vu
vs = 4294967295 ; vu = 4294967295
print x4 $ vs $ vu
let vs + + vu + +
print x5 $ vs $ vu
let vs + + vu + +
print x6 $ vs $ vu
expected - stdout:
x1 - 1 4294967295
x2 2147483647 2147483647
x3 - 2147483648 2147483648
x4 - 1 4294967295
x5 0 0
x6 1 1
- - -
2005-05-23 05:06:10 +02:00
name: bksl - nl - ign - 1
description:
Check that \ newline is not collasped after #
stdin:
echo hi #there \
echo folks
expected - stdout:
hi
folks
- - -
name: bksl - nl - ign - 2
description:
Check that \ newline is not collasped inside single quotes
stdin:
echo ' hi \
there '
echo folks
expected - stdout:
hi \
there
folks
- - -
name: bksl - nl - ign - 3
description:
Check that \ newline is not collasped inside single quotes
stdin:
cat << \ EOF
hi \
there
EOF
expected - stdout:
hi \
there
- - -
2007-09-08 01:57:14 +02:00
name: bksl - nl - ign - 4
2005-05-23 05:06:10 +02:00
description:
Check interaction of aliases , single quotes and here - documents
with backslash - newline
( don ' t know what posix has to say about this )
2005-07-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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-08 01:57:14 +02:00
name: bksl - nl - ign - 5
2005-05-23 05:06:10 +02:00
description:
Check what happens with backslash at end of input
( the old bourne shell trashes them ; so do we )
stdin: !
echo `echo foo\\` bar
echo hi \
expected - stdout:
foobar
hi
- - -
#
# Places \newline should be collapsed
#
name: bksl - nl - 1
description:
Check that \ newline is collasped before , in the middle of , and
after words
stdin:
\
echo hi \
There , \
folks
expected - stdout:
hiThere , folks
- - -
name: bksl - nl - 2
description:
Check that \ newline is collasped in $ sequences
( 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:
Check that \ newline is collasped in $( .. ) and `...` sequences
( 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:
Check that \ newline is collasped in $( ( .. ) ) sequences
( 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:
Check that \ newline is collasped in double quoted strings
stdin:
echo " \
hi "
echo " foo \
bar "
echo " folks \
"
expected - stdout:
hi
foobar
folks
- - -
name: bksl - nl - 6
description:
Check that \ newline is collasped in here document delimiters
( 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:
Check that \ newline is collasped in double - quoted here - document
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:
Check that \ newline is collasped in various 2 + character tokens
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-08 01:57:14 +02:00
name: bksl - nl - 9
2005-05-23 05:06:10 +02:00
description:
Check that \ at the end of an alias is collapsed when followed
by a newline
( don ' t know what posix has to say about this )
2005-07-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02:00
alias x = ' echo hi \ '
x
echo there
expected - stdout:
hiecho there
- - -
2007-09-08 01:57:14 +02:00
name: bksl - nl - 10
2005-05-23 05:06:10 +02:00
description:
Check that \ newline in a keyword is collapsed
2005-07-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02:00
i \
f true ; then \
echo pass ; el \
se echo fail ; fi
expected - stdout:
pass
- - -
#
# Places \newline should be collapsed (ksh extensions)
#
2007-09-08 01:57:14 +02:00
name: bksl - nl - ksh - 1
2005-05-23 05:06:10 +02:00
description:
Check that \ newline is collapsed in extended globbing
( ksh93 fails this )
2005-07-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02:00
xxx = foo
case $ xxx in
( f * \
( \
o \
) \
) echo ok ; ;
* ) echo bad
esac
expected - stdout:
ok
- - -
2007-09-08 01:57:14 +02:00
name: bksl - nl - ksh - 2
2005-05-23 05:06:10 +02:00
description:
Check that \ newline is collapsed in ( ( ... ) ) expressions
( ksh93 fails this )
2005-07-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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
- - -
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
arguments: ! - i !
stdin:
echo hi $ { XXX } there
expected - stdout:
hi_there
expected - stderr: !
XX
- - -
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 14:42:21 +02:00
( AT & T ksh fails this test )
2005-05-23 05:06:10 +02: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 12:24:12 +01:00
Eglobbing in trim expressions ...
2009-06-11 14:42:21 +02:00
( AT & T ksh fails this - docs say # matches shortest string, ## matches
2005-05-23 05:06:10 +02: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 12:24:12 +01:00
Check eglobbing works in trims ...
2005-05-23 05:06:10 +02: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
- - -
2008-02-27 12:24:12 +01:00
name: eglob - substrpl - 1
description:
Check eglobbing works in substs ... and they work at all
stdin:
2008-03-01 22:24:58 +01:00
[ [ - n $ BASH_VERSION ] ] && shopt - s extglob
2008-02-27 12:24:12 +01:00
x = 1222321 _ab /cde_b/c _1221
2008-03-01 22:24:58 +01:00
y = xyz
2008-02-27 12:24:12 +01: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 // / . }
echo 23 : $ { x // #1/9}
echo 24 : $ { x // % 1 / 9 }
echo 25 : $ { x // \ % 1 / 9 }
2008-02-27 13:49:54 +01:00
echo 26 : $ { x // \ \ % 1 / 9 }
echo 27 : $ { x // \ a / 9 }
echo 28 : $ { x // \ \ a / 9 }
2008-03-01 22:24:58 +01:00
echo 29 : $ { x /2/ $ y }
2008-02-27 12:24:12 +01: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
24 : 1222321 _ab /cde_b/c _1229
25 : 1222321 _ab /cde_b/c _1229
2008-02-27 13:49:54 +01:00
26 : 1222321 _ab /cde_b/c _1221
27 : 1222321_9 b /cde_b/c _1221
28 : 1222321_9 b /cde_b/c _1221
2008-03-01 22:24:58 +01:00
29 : 1 xyz22321_ab /cde_b/c _1221
2008-02-27 12:24:12 +01:00
- - -
2008-03-01 17:40:57 +01: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 22:10:26 +01:00
name: eglob - substrpl - 3 a
2008-03-01 17:40:57 +01:00
description:
Check substring replacement works with variables and slashes , too
stdin:
pfx = /home/ user
wd = /home/ user / tmp
2009-07-19 13:03:18 +02:00
echo "${wd/#$pfx/~}"
echo "${wd/#\$pfx/~}"
echo "${wd/#" $ pfx "/~}"
echo "${wd/#'$pfx'/~}"
echo "${wd/#" \ $ pfx "/~}"
echo "${wd/#'\$pfx'/~}"
2008-03-01 22:10:26 +01:00
expected - stdout:
~ / tmp
/home/ user / tmp
~ / tmp
/home/ user / tmp
/home/ user / tmp
/home/ user / tmp
- - -
name: eglob - substrpl - 3 b
description:
2009-07-19 13:03:18 +02:00
More of this , bash fails it ( bash4 passes )
2008-03-01 22:10:26 +01:00
stdin:
pfx = /home/ user
wd = /home/ user / tmp
2009-07-19 13:03:18 +02:00
echo "${wd/#$(echo /home/user)/~}"
echo "${wd/#" $ ( echo /home/ user ) "/~}"
echo "${wd/#'$(echo /home/user)'/~}"
2008-03-01 17:40:57 +01:00
expected - stdout:
~ / tmp
2008-03-01 18:14:17 +01:00
~ / tmp
/home/ user / tmp
2008-03-01 17:40:57 +01:00
- - -
2008-03-01 22:10:26 +01:00
name: eglob - substrpl - 3 c
description:
Even more weird cases
stdin:
pfx = /home/ user
wd = '$pfx/tmp'
2008-03-01 23:58:22 +01: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 }
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 }
echo 30 : $ { ts // + ( a \ /b)/ $ tr }
echo 31 : $ { ts // + ( a \ /b)/ \ $ tr }
echo 32 : $ { ts // + ( $ tp ) / $ tr }
echo 33 : $ { ts // + ( $ tp ) /c/ d }
echo 34 : $ { ts // + ( $ tp ) / c \ / d }
tp = "+($tp)"
echo 40 : $ { ts /$tp/ $ tr }
echo 41 : $ { ts // $ tp / $ tr }
2008-03-01 22:10:26 +01:00
expected - stdout:
2008-03-01 23:58:22 +01:00
1 : $ pfx / tmp
2 : ~ / tmp
3 : $ pfx / tmp
4 : ~ / tmp
5 : ~ / tmp
6 : ~ / tmp
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 )
11 : c /da/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
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 )
25 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
26 : $ tr $ tr $ tp $ tp_ $ tr $ tp_ * ( $ tr ) _ * ( $ tp )
27 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
28 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
29 : c /dc/ d $ tp $ tp_c /d$tp_*(c/ d ) _ * ( $ tp )
30 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
31 : $ tr $ tp $ tp_ $ tr $ tp_ * ( $ tr ) _ * ( $ tp )
32 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
33 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
34 : c /d$tp$tp_c/ d $ tp_ * ( c / d ) _ * ( $ tp )
40 : a /ba/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
41 : a /ba/ b $ tp $ tp_a /b$tp_*(a/ b ) _ * ( $ tp )
# This is what GNU bash does:
# 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
# 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2008-03-01 22:10:26 +01:00
- - -
2005-05-23 05:06:10 +02: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
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 ] *
expected - stdout:
- bc abc bbc
- bc abc bbc
cbc
- bc cbc
abc bbc
- - -
name: glob - range - 2
description:
Test range matching
2009-06-11 14:42:21 +02:00
( AT & T ksh fails this ; POSIX says invalid )
2005-05-23 05:06:10 +02: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 23:46:12 +02:00
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2005-05-23 16:48:21 +02:00
category: ! os:darwin
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
( AT & T ksh treats this like [ a - cc - e ] * )
2005-05-23 05:06:10 +02: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
- - -
name: heredoc - 1
description:
Check ordering / content of redundent here documents .
stdin:
2005-07-08 01:27:52 +02:00
cat << EOF1 << EOF2
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
stdin:
2005-05-23 05:06:10 +02: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 21:43:11 +01:00
name: heredoc - 9 a
description:
Check that here strings work .
stdin:
bar = " bar
baz "
2008-02-29 17:38:41 +01:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < foo
2008-04-01 18:04:58 +02:00
"$__progname" - c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2008-02-29 17:38:41 +01:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < "$bar"
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < '$bar'
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < \ $ bar
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < - foo
2008-02-26 21:43:11 +01:00
expected - stdout:
sbb
sbb
one
onm
$ one
$ one
- sbb
- - -
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 17:38:41 +01:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < $ bar
2008-02-26 21:43:11 +01: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 17:38:41 +01:00
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < $ bar
2008-02-26 21:43:11 +01:00
expected - stdout:
one
$ sabeq onm
- - -
2008-07-09 22:31:19 +02:00
name: heredoc - 9 d
description:
Check another corner case of here strings
stdin:
tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm << < bar
expected - stdout:
one
- - -
2005-11-22 19:36:20 +01: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
- - -
2005-05-23 05:06:10 +02: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 14:57:35 +01: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 .
2005-05-23 05:06:10 +02: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: *
- - -
name: history - basic
description:
See if we can test history at all
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 20:43:07 +02:00
name: history - dups
description:
Verify duplicates and spaces are not entered
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-07 00:41:09 +02:00
name: history - unlink
description:
Check if broken HISTFILEs do not cause trouble
2008-07-11 02:23:59 +02:00
category: ! os:cygwin
2008-07-07 00:41:09 +02: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:
2008-07-10 22:05:01 +02:00
/(.*cannot unlink HISTFILE.*\n)?X*$/
2008-07-07 00:41:09 +02:00
- - -
2005-05-23 05:06:10 +02:00
name: history - e - minus - 1
description:
Check if more recent command is executed
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 .
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 )
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 .
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 .
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 21:36:16 +02:00
:
2005-05-23 05:06:10 +02:00
fc - e - echo
2008-09-30 21:36:16 +02:00
fc - l 2 5
2005-05-23 05:06:10 +02:00
expected - stdout:
abc def
ghi jkl
ghi jkl
2 echo ghi jkl
2008-09-30 21:36:16 +02:00
3 :
4 echo ghi jkl
5 fc - l 2 5
2005-05-23 05:06:10 +02: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 )
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 )
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
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
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
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 )
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
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
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 .
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 .
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
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 ?
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
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 )
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 )
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 18:17:00 +02:00
name: history - ed - 1 - old
description:
Basic ( ed ) editing works ( assumes you have generic ed editor
2005-05-23 18:23:19 +02:00
that prints no prompts ) . This is for oldish ed ( 1 ) which write
2007-01-18 02:10:55 +01:00
the character count to stdout .
2008-11-08 18:36:35 +01:00
category: stdout - ed
2005-05-23 18:17:00 +02: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 18:36:35 +01:00
category: stdout - ed
2005-05-23 18:17:00 +02: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 .
2005-05-23 18:23:19 +02:00
( NOTE: adjusted for COMPLEX HISTORY compile time option )
2005-05-23 18:17:00 +02:00
( ksh88 fails ' cause it lists the fc command )
2008-11-08 18:36:35 +01:00
category: stdout - ed
2005-05-23 18:17:00 +02: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
2005-05-23 18:23:19 +02:00
3 echo a new line
2005-05-23 18:17:00 +02:00
expected - stderr - pattern:
/^X*echo FOOBAR def\necho a new line\nX*$/
- - -
2005-05-23 05:06:10 +02:00
name: history - ed - 1
description:
Basic ( ed ) editing works ( assumes you have generic ed editor
2005-05-23 18:23:19 +02:00
that prints no prompts ) . This is for newish ed ( 1 ) and stderr .
2008-11-08 18:36:35 +01:00
category: ! no - stderr - ed
2005-05-23 05:06:10 +02: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 17:02:04 +02:00
/^X*13\n16\necho FOOBAR def\nX*$/
2005-05-23 05:06:10 +02:00
- - -
name: history - ed - 2
description:
Correct command is edited when number given
2008-11-08 18:36:35 +01:00
category: ! no - stderr - ed
2005-05-23 05:06:10 +02: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 17:02:04 +02:00
/^X*20\n23\necho line 2 is changed\nX*$/
2005-05-23 05:06:10 +02:00
- - -
name: history - ed - 3
description:
Newly created multi line commands show up as single command
in history .
2008-11-08 18:36:35 +01:00
category: ! no - stderr - ed
2005-05-23 05:06:10 +02: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
2005-05-23 17:02:04 +02:00
3 echo a new line
2005-05-23 05:06:10 +02:00
expected - stderr - pattern:
2005-05-23 17:02:04 +02:00
/^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
2005-05-23 05:06:10 +02:00
- - -
name: IFS - space - 1
description:
Simple test , default IFS
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
<1> <A> <B> <C>
<2> < A B C >
<3> <A> <B> <C>
<4> <A> <B> <C>
- - -
name: IFS - colon - 1
description:
Simple test , IFS = :
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = :
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
<1> <A> <B> <C>
<2> <A:B:C>
<3> <A> <B> <C>
<4> <A> <B> <C>
- - -
name: IFS - null - 1
description:
Simple test , IFS = ""
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = ""
set - - A B C
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
expected - stdout:
<1> < A B C >
<2> <ABC>
<3> < A B C >
<4> < A B C >
- - -
name: IFS - space - colon - 1
description:
Simple test , IFS = <white-space> :
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = "$IFS:"
set - -
showargs 1 $*
showargs 2 "$*"
showargs 3 $@
showargs 4 "$@"
showargs 5 : "$@"
expected - stdout:
<1>
<2> < >
<3>
<4>
<5> <:>
- - -
name: IFS - space - colon - 2
description:
Simple test , IFS = <white-space> :
2009-06-11 14:42:21 +02:00
AT & T ksh fails this , POSIX says the test is correct .
2005-05-23 05:06:10 +02:00
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = "$IFS:"
set - -
showargs : "$@"
expected - stdout:
<:>
- - -
name: IFS - space - colon - 3
description:
Simple test , IFS = <white-space> :
pdksh fails both of these tests
2006-08-02 14:38:45 +02:00
not sure whether #2 is correct
2005-05-23 05:06:10 +02:00
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = "$IFS:"
x =
set - -
2006-08-02 14:38:45 +02:00
showargs "$x$@" 1
showargs "$@$x" 2
2005-05-23 05:06:10 +02:00
expected - fail: yes
expected - stdout:
2006-08-02 14:38:45 +02:00
< > <1>
< > <2>
2005-05-23 05:06:10 +02:00
- - -
name: IFS - space - colon - 4
description:
Simple test , IFS = <white-space> :
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = "$IFS:"
set - -
showargs "$@$@"
expected - stdout:
- - -
name: IFS - space - colon - 5
description:
Simple test , IFS = <white-space> :
2009-06-11 14:42:21 +02:00
Don ' t know what POSIX thinks of this . AT & T ksh does not do this .
2005-05-23 05:06:10 +02:00
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
IFS = "$IFS:"
set - -
showargs "${@:-}"
expected - stdout:
< >
- - -
name: IFS - subst - 1
description:
Simple test , IFS = <white-space> :
stdin:
showargs ( ) { for i ; do echo - n " <$i>" ; done ; echo ; }
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:: ]
<3> < > <b> < >
<4> <:b::>
5 : [ a ] [ b ]
<6> <a> <b>
7 : [ a ] [] [ c ]
<8> <a> < > <c>
9 : [ h ] [ ith ] [ ere ]
<10> <h> <ith> <ere>
<11> <h:ith:ere>
12 : [ A ] [ B ] [] [ D ]
<13> <A> <B> < > <D>
- - -
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 )
arguments: ! - i !
stdin:
2007-01-12 11:18:22 +01:00
PS1 = # minimise prompt hassles
2005-05-23 05:06:10 +02: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 19:42:55 +02:00
j = '~3'
2005-05-23 05:06:10 +02: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
- - -
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
- - -
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 ]
- - -
name: read - ksh - 1
description:
If no var specified , REPLY is used
stdin:
echo "abc" > IN
read < IN
echo "[$REPLY]" ;
expected - stdout:
[ abc ]
- - -
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:
: $ { PWD: - `pwd 2> /dev/null` }
: $ { PWD: ? "PWD not set - can't do test" }
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:
echo $ ( echo \ ( )
expected - stdout:
(
- - -
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
- - -
name: regression - 10
description:
The following:
set - - `false`
echo $?
2009-06-11 14:42:21 +02:00
shoud not print 0 . ( according to /bin/s h , AT & T ksh88 , and the
2005-05-23 05:06:10 +02:00
getopt ( 1 ) man page - not according to POSIX )
stdin:
set - - `false`
echo $?
expected - stdout:
1
- - -
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
2008-07-10 21:06:15 +02:00
( : ; cat t2 2 > & - ) | sleep 1
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
generates an error under /bin/s h and pdksh , but AT & T ksh88 produces
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
AT & T ksh88 generates no output and sets the exit status to 1 . Also ,
2005-05-23 05:06:10 +02:00
the command
$ whence foobar cat
2009-06-11 14:42:21 +02:00
generates no output under AT & T ksh88 ( pdksh generates a blank line
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
should set the exit status to non - zero ( sh and AT & T ksh88 do ) .
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
asks for more info . sh and AT & T ksh88 both echo
2005-05-23 05:06:10 +02: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 14:42:21 +02:00
alias expansion different from AT & T ksh88
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
echo 1 : $ { x - x not set } $ { y - y not set } $ { z - z not set }
2005-05-23 05:06:10 +02: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:
umask 222
umask
expected - stdout:
0222
- - -
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-08 01:27:52 +02:00
( echo abcdef ; echo ; echo 123 ) |
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
while false ; do echo hi ; done
2005-05-23 05:06:10 +02:00
echo ok
expected - stdout:
ok
- - -
name: regression - 39
description:
set - e: errors in command substitutions aren ' t ignored
2005-07-04 14:48:12 +02:00
Not clear if they should be or not ... bash passes here
2006-08-02 14:38:45 +02:00
this may actually be required for make , so changed the
test to make this an mksh feature , not a bug
2005-05-23 05:06:10 +02:00
arguments: ! - e !
stdin:
echo `false; echo hi`
2006-08-02 14:38:45 +02:00
#expected-fail: yes
#expected-stdout:
# hi
expected - fail: no
2005-05-23 05:06:10 +02:00
expected - stdout:
2006-08-02 14:38:45 +02:00
2005-05-23 05:06:10 +02: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:
foo = bar
readonly foo
foo = stuff env | grep '^foo'
expected - exit : e != 0
expected - stderr - pattern:
/.*read *only.*/
- - -
name: regression - 43
description:
Can subshells be prefixed by redirections ( historical shells allow
this )
stdin:
< /dev/ null ( sed 's/^/X/' )
- - -
name: regression - 44
description:
getopts sets OPTIND correctly for unparsed option
stdin:
set - - - a - a - x
while getopts : a optc ; do
echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
done
echo done
expected - stdout:
OPTARG = , OPTIND = 2 , optc = a .
OPTARG = , OPTIND = 3 , optc = a .
OPTARG = x , OPTIND = 3 , optc = ? .
done
- - -
name: regression - 45
description:
2007-01-12 11:18:22 +01:00
Parameter assignments with [] recognised correctly
2005-05-23 05:06:10 +02: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 18:01:45 +02:00
TMPDIR = $ PWD / foo "$__progname" << - 'EOF'
2005-05-23 05:06:10 +02: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 18:01:45 +02:00
TMPDIR = $ PWD / foo "$__progname" << - 'EOF'
2005-05-23 05:06:10 +02: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 .
file - setup: file 644 "env"
PS1 = Y
PS2 = X
env - setup: ! ENV = . / env !
arguments: ! - i !
stdin:
alias foo = 'echo hi ; '
foo
foo echo there
2005-07-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
A: a b c , *
- - -
name: regression - 52
description:
2008-02-27 12:24:12 +01:00
Check that globbing works in pipelined commands
2005-05-23 05:06:10 +02:00
file - setup: file 644 "env"
PS1 = P
file - setup: file 644 "abc"
stuff
env - setup: ! ENV = . / env !
arguments: ! - i !
stdin:
sed 's/^/X /' < ab *
echo mark 1
sed 's/^/X /' < ab * | sed 's/^/Y /'
echo mark 2
2005-07-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
1 fooXbar
2 fooXbar
3 foo
4 foo
5 barXblah
6 barXblah
7 blah
8 blah
- - -
name: regression - 56
description:
Check eval vs substitution exit codes
( this is what ksh88 does )
stdin:
eval $ ( false )
echo A $?
eval ' $(false)'
echo B $?
eval " $(false)"
echo C $?
eval "eval $(false)"
echo D $?
eval 'eval ' "$(false)"
echo E $?
IFS = "$IFS:"
eval $ ( echo : ; false )
echo F $?
2005-07-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
A 1
B 1
C 1
D 0
E 0
F 1
- - -
name: regression - 57
description:
Check if typeset output is correct for
2007-01-12 11:18:22 +01:00
uninitialised array elements .
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
A
xxx
B
typeset - i xxx
M
xxx [ 1 ] = 7
N
typeset - i xxx
- - -
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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
hi
- - -
name: regression - 59
description:
Check if $ { #array[*]} is calculated correctly.
stdin:
a [ 12 ] = hi
a [ 8 ] = there
echo $ { #a[*]}
2005-07-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02: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-08 01:27:52 +02:00
expected - stdout:
2005-05-23 05:06:10 +02:00
nt OK
ot OK
- - -
2008-04-01 18:12:18 +02:00
name: regression - 63
description:
Check if typeset , export , and readonly work
stdin:
{
print FNORD - 0
FNORD_A = 1
FNORD_B = 2
FNORD_C = 3
FNORD_D = 4
2008-04-01 23:39:45 +02:00
FNORD_E = 5
FNORD_F = 6
FNORD_G = 7
FNORD_H = 8
2008-04-01 23:07:20 +02: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
2008-04-01 18:12:18 +02:00
print FNORD - 1
export
print FNORD - 2
export - p
print FNORD - 3
readonly
print FNORD - 4
readonly - p
print FNORD - 5
typeset
print FNORD - 6
2008-04-01 23:07:20 +02:00
typeset - p
print FNORD - 7
2008-04-01 23:39:45 +02:00
typeset -
print FNORD - 8
2008-04-01 18:12:18 +02:00
} | fgrep FNORD
expected - stdout:
FNORD - 0
FNORD - 1
FNORD_C
FNORD_D
2008-04-01 23:07:20 +02:00
FNORD_G
FNORD_H
2008-04-01 18:12:18 +02:00
FNORD - 2
export FNORD_C = 3
export FNORD_D = 4
2008-04-01 23:39:45 +02:00
export FNORD_G = 7
export FNORD_H = 8
2008-04-01 18:12:18 +02:00
FNORD - 3
FNORD_B
FNORD_D
2008-04-01 23:07:20 +02:00
FNORD_F
FNORD_H
2008-04-01 18:12:18 +02:00
FNORD - 4
readonly FNORD_B = 2
readonly FNORD_D = 4
2008-04-01 23:39:45 +02:00
readonly FNORD_F = 6
readonly FNORD_H = 8
2008-04-01 18:12:18 +02:00
FNORD - 5
typeset FNORD_A
typeset - r FNORD_B
typeset - x FNORD_C
typeset - x - r FNORD_D
2008-04-01 23:07:20 +02:00
typeset - i FNORD_E
typeset - i - r FNORD_F
typeset - i - x FNORD_G
typeset - i - x - r FNORD_H
2008-04-01 18:12:18 +02:00
FNORD - 6
2008-04-01 23:07:20 +02: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 23:39:45 +02:00
FNORD_E = 5
FNORD_F = 6
FNORD_G = 7
FNORD_H = 8
2008-04-01 23:07:20 +02:00
FNORD - 8
2008-04-01 18:12:18 +02:00
- - -
2008-07-14 14:29:06 +02: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
}
- - -
2005-05-23 05:06:10 +02: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
- - -
name: xxx - exec - environment - 1
description:
Check to see if exec sets it ' s environment correctly
stdin:
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:
2009-03-21 12:09:35 +01:00
sortprog = $ ( whence - p sort ) || sortprog = cat
env | $ sortprog > bar1
FOO = bar exec ; env | $ sortprog > bar2
2005-05-23 05:06:10 +02:00
cmp - s bar1 bar2
- - -
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
- - -
2006-08-14 22:41:21 +02:00
name: xxx - substitution - eval - order
2005-05-23 05:06:10 +02: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
arguments: ! - i !
stdin:
exec print hi
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 $?
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 .
2005-07-04 14:27:28 +02:00
ksh88 , Solaris /bin/s h and /usr/x pg4 /bin/s h all print the error ,
that ' s why the condition is reversed .
2005-05-23 05:06:10 +02:00
stdin:
unset foo
x =
echo x $ { foo ? $ x }
expected - exit : 1
2005-07-04 14:27:28 +02:00
# POSIX
#expected-fail: yes
#expected-stderr-pattern: !/not set/
# common use
expected - stderr - pattern: /parameter null or not set/
2005-05-23 05:06:10 +02:00
- - -
name: xxx - param - _ - 1
2007-07-01 21:04:53 +02:00
# fails due to weirdness of execv stuff
category: ! os:uwin - nt
2005-05-23 05:06:10 +02:00
description:
Check c flag is set .
arguments: ! - c ! echo "[$-]" !
expected - stdout - pattern: /^\[.*c.*\]$/
- - -
2005-05-25 16:20:53 +02:00
name: tilde - expand - 1
description:
Check tilde expansion after equal signs
env - setup: ! HOME = / sweet !
stdin:
echo $ { A = a = } ~ b =~ c = d ~ ~
2005-07-04 14:27:28 +02:00
set + o braceexpand
2005-05-25 16:20:53 +02:00
echo $ { A = a = } ~ b =~ c = d ~ ~
expected - stdout:
a = /sweet b=/s weet c = d ~ / sweet
a =~ b =~ c = d ~ / sweet
- - -
2005-05-25 16:39:33 +02:00
name: errexit - 1
description:
Check some "exit on error" conditions
stdin:
set - ex
/usr/ bin / env false && echo something
echo END
expected - stdout:
END
expected - stderr:
+ /usr/ bin / env false
+ echo END
- - -
name: errexit - 2
description:
2009-03-22 16:47:23 +01:00
Check some "exit on error" edge conditions ( POSIXly )
2005-05-25 16:39:33 +02:00
stdin:
set - ex
if /usr/ bin / env true ; then
/usr/ bin / env false && echo something
fi
echo END
expected - stdout:
2009-03-22 16:47:23 +01:00
END
2005-05-25 16:39:33 +02:00
expected - stderr:
+ /usr/ bin / env true
+ /usr/ bin / env false
2009-03-22 16:47:23 +01:00
+ echo END
2005-05-25 16:39:33 +02:00
- - -
2007-07-24 13:22:04 +02:00
name: errexit - 3
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-03-22 16:47:23 +01:00
name: errexit - 4
description:
"set -e" test suite ( POSIX )
stdin:
set - e
echo pre
if true ; then
false && echo foo
fi
echo bar
expected - stdout:
pre
bar
- - -
name: errexit - 5
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
- - -
name: errexit - 6
description:
"set -e" test suite ( BSD make )
category: os:mirbsd
stdin:
mkdir zd zd /a zd/ b
2009-03-22 19:28:35 +01: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 16:47:23 +01: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 ) .
- - -
2006-08-14 22:41:21 +02:00
name: test - stlt - 1
2005-10-08 21:31:00 +02: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 22:41:21 +02: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 21:31:00 +02:00
expected - stdout:
nein
ja
2006-08-14 22:41:21 +02:00
ja
nein
2005-10-08 21:31:00 +02:00
expected - stderr - pattern: ! /unexpected op/
- - -
2009-03-22 19:28:35 +01:00
name: test - precedence - 1
description:
Check a weird precedence case ( and POSIX echo )
stdin:
test \ ( - f = - f \ )
rv = $?
set - o posix
echo - e $ rv
expected - stdout:
- e 0
- - -
2006-05-08 13:59:41 +02: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 21:27:35 +02:00
name: mkshrc - 2 a
2006-05-08 13:59:41 +02:00
description:
Check that ~ / . mkshrc works correctly .
2006-06-21 21:27:35 +02:00
Part 2 : verify mkshrc is not read ( non - interactive shells )
2006-05-08 13:59:41 +02:00
file - setup: file 644 ".mkshrc"
FNORD = 42
env - setup: ! HOME = . ! ENV = !
2006-06-21 21:27:35 +02: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
arguments: ! - i !
env - setup: ! HOME = . ! ENV = ! PS1 = !
2006-05-08 13:59:41 +02:00
stdin:
echo x $ FNORD
expected - stdout:
x 42
2006-07-07 11:52:20 +02:00
expected - stderr - pattern:
/(# )*/
2006-05-08 13:59:41 +02: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
- - -
2006-08-09 22:21:08 +02:00
name: posix - mode - 1
description:
Check that posix mode turns braceexpand off
and that that works correctly
stdin:
set - o braceexpand
set + o posix
2008-04-20 00:03:19 +02:00
[ [ $ ( set + o ) == * @ ( - o posix ) @ ( | * ) ] ] && echo posix || echo noposix
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 22:21:08 +02:00
echo { a , b , c }
set + o braceexpand
echo { a , b , c }
set - o braceexpand
echo { a , b , c }
set - o posix
echo { a , b , c }
2008-04-20 00:03:19 +02:00
[ [ $ ( set + o ) == * @ ( - o posix ) @ ( | * ) ] ] && echo posix || echo noposix
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 22:21:08 +02:00
set - o braceexpand
echo { a , b , c }
2008-04-20 00:03:19 +02:00
[ [ $ ( set + o ) == * @ ( - o posix ) @ ( | * ) ] ] && echo posix || echo noposix
[ [ $ ( set + o ) == * @ ( - o braceexpand ) @ ( | * ) ] ] && echo brex || echo nobrex
2006-08-09 22:21:08 +02:00
expected - stdout:
noposix
brex
a b c
{ a , b , c }
a b c
{ a , b , c }
posix
nobrex
a b c
posix
brex
- - -
2008-10-20 21:29:25 +02:00
name: posix - mode - 2 a
description:
Check that posix mode is * not * automatically turned on
category: ! binsh
stdin:
ln - s "$__progname" ksh
ln - s "$__progname" sh
ln - s "$__progname" . / - ksh
ln - s "$__progname" . / - sh
for shell in { , - } { , k } sh ; do
print - - $ shell $( . / $ shell + l - c \
'[[ $(set +o) == *@(-o posix)@(| *) ]] && echo posix || echo noposix' )
done
expected - stdout:
sh noposix
ksh noposix
- sh noposix
- ksh noposix
- - -
name: posix - mode - 2 b
2008-09-17 21:31:30 +02:00
description:
Check that posix mode is automatically turned on
2008-10-20 21:29:25 +02:00
category: binsh
2008-09-17 21:31:30 +02:00
stdin:
ln - s "$__progname" ksh
ln - s "$__progname" sh
2008-09-19 12:41:55 +02:00
ln - s "$__progname" . / - ksh
ln - s "$__progname" . / - sh
2008-09-17 21:31:30 +02:00
for shell in { , - } { , k } sh ; do
print - - $ shell $( . / $ shell + l - c \
'[[ $(set +o) == *@(-o posix)@(| *) ]] && echo posix || echo noposix' )
done
expected - stdout:
sh posix
ksh noposix
- sh posix
- ksh noposix
- - -
2007-10-25 15:51:19 +02:00
name: pipeline - 1
2006-08-14 22:36:39 +02: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 15:51:19 +02:00
name: pipeline - 2
description:
check that co - processes work with TCOMs , TPIPEs and TPARENs
stdin:
2008-04-01 18:01:45 +02:00
"$__progname" - c 'i=100; print hi |& while read -p line; do print "$((i++)) $line"; done'
"$__progname" - c 'i=200; print hi | cat |& while read -p line; do print "$((i++)) $line"; done'
"$__progname" - c 'i=300; (print hi | cat) |& while read -p line; do print "$((i++)) $line"; done'
2007-10-25 15:51:19 +02:00
expected - stdout:
100 hi
200 hi
300 hi
- - -
2006-08-24 22:50:02 +02:00
name: persist - history - 1
description:
Check if persistent history saving works
2008-06-21 21:20:15 +02:00
category: ! no - histfile
2006-08-24 22:50:02 +02: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*$/
- - -
2006-11-10 02:13:52 +01: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 "
print "<$ln> <$rn> <$lz> <$rz> <$rx>"
expected - stdout:
< 0 hall0 > < 0 hall0 > < hall0 > <00000hall0> < 0000 hallo >
- - -
2008-04-19 23:04:09 +02: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
print "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
expected - stdout:
< 16 #1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
- - -
2007-04-15 12:45:59 +02: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 23:46:12 +02:00
# breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2008-06-21 21:20:15 +02:00
category: ! os:darwin
2007-04-15 12:45:59 +02: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 / *
print got $ { #anzahl[*]} files
chmod + x foo / *
export PATH = $ ( pwd ) / foo: $ PATH
2008-04-01 18:01:45 +02:00
"$__progname" - c ' fnord'
2009-04-08 20:00:53 +02:00
echo =
2008-04-01 18:01:45 +02:00
"$__progname" - c ' fnord; fnord; fnord; fnord'
2009-04-08 20:00:53 +02:00
echo =
2008-04-01 18:01:45 +02:00
"$__progname" foo / bar
2009-04-08 20:00:53 +02:00
echo =
2008-04-01 18:01:45 +02:00
"$__progname" < foo / bar
2009-04-08 20:00:53 +02:00
echo =
2008-04-01 18:01:45 +02:00
"$__progname" foo / zoo
2009-04-08 20:00:53 +02:00
echo =
2008-04-01 18:01:45 +02:00
"$__progname" - c 'print : $( fnord)'
2007-04-15 12:45:59 +02:00
rm - rf foo
expected - stdout:
got 4 files
ohne
2009-04-08 20:00:53 +02:00
=
2007-04-15 12:45:59 +02:00
ohne
ohne
mit
ohne
2009-04-08 20:00:53 +02:00
=
2007-04-15 12:45:59 +02:00
ohne
ohne
mit
ohne
2009-04-08 20:00:53 +02:00
=
2007-04-15 12:45:59 +02:00
ohne
ohne
mit
ohne
2009-04-08 20:00:53 +02:00
=
2007-04-15 12:45:59 +02:00
ohne
ohne
mit
ohne
2009-04-08 20:00:53 +02:00
=
2007-04-15 12:45:59 +02:00
: mit
- - -
2008-04-01 19:25:37 +02:00
name: utf8bom - 2
2007-04-15 12:58:55 +02:00
description:
2009-04-08 20:00:53 +02:00
Check that we can execute BOM - shebangs ( failures not fatal )
2007-04-15 14:09:57 +02:00
XXX if the OS can already execute them , we lose
2007-04-17 16:00:00 +02:00
note: cygwin execve ( 2 ) doesn ' t return to us with ENOEXEC , we lose
2008-04-02 19:09:45 +02:00
note: Ultrix perl5 t4 returns 65280 ( exit - code 255 ) and no text
2008-07-11 21:51:23 +02:00
category: ! os:cygwin , ! os:uwin - nt , ! os:ultrix , ! smksh
2008-04-01 19:22:54 +02:00
env - setup: ! FOO = BAR !
stdin:
2009-04-08 20:00:53 +02: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 19:22:54 +02:00
chmod + x t ?
. / t1
. / t2
. / t3
. / t4
expected - stdout:
2009-04-08 20:00:53 +02:00
1 a = / nonexistant { FOO }
2 a = / nonexistant { FOO }
3 a = BAR
4 a = BAR
2008-04-01 19:22:54 +02:00
expected - stderr - pattern:
2008-04-01 19:25:37 +02:00
/(Unrecognized character .... ignored at \..t4 line 1)*/
2008-04-01 19:22:54 +02:00
- - -
2007-04-15 14:28:38 +02:00
name: utf8bom - 3
description:
2008-12-04 19:11:08 +01:00
Reading the UTF - 8 BOM should enable the utf8 - mode flag
2007-04-15 14:28:38 +02:00
stdin:
2009-04-08 20:00:53 +02:00
"$__progname" - c ':; if [[ $- = *U* ]]; then print 1 on; else print 1 off; fi'
"$__progname" - c ' :; if [[ $- = *U* ]]; then print 2 on; else print 2 off; fi'
2007-04-15 14:28:38 +02:00
expected - stdout:
2009-04-08 20:00:53 +02:00
1 off
2 on
2007-04-15 14:28:38 +02:00
- - -
2008-07-08 22:54:33 +02: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-20 00:15:06 +02:00
description:
2008-12-04 19:11:08 +01:00
Check that the utf8 - mode flag is not set at non - interactive startup
2008-07-10 23:25:00 +02:00
category: ! os:hpux
2008-07-08 22:54:33 +02:00
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . UTF - 8 !
stdin:
2008-12-13 18:02:18 +01:00
if [ [ $- = * U * ] ] ; then
2008-07-08 22:54:33 +02:00
print is set
else
print is not set
fi
expected - stdout:
is not set
- - -
name: utf8opt - 1 b
description:
2008-12-04 19:11:08 +01:00
Check that the utf8 - mode flag is not set at non - interactive startup
2008-07-10 23:20:22 +02:00
category: os:hpux
2008-05-04 03:38:04 +02: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-20 00:15:06 +02:00
stdin:
2008-12-13 18:02:18 +01:00
if [ [ $- = * U * ] ] ; then
• 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-20 00:15:06 +02:00
print is set
else
print is not set
fi
expected - stdout:
is not set
- - -
2008-06-02 22:44:07 +02: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-20 00:15:06 +02:00
description:
2009-08-01 23:57:52 +02: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
2008-07-10 23:20:22 +02:00
category: ! os:hpux
2008-06-02 22:44:07 +02:00
arguments: ! - i !
env - setup: ! PS1 = ! PS2 = ! LC_CTYPE = en_US . UTF - 8 !
stdin:
2008-12-13 18:02:18 +01:00
if [ [ $- = * U * ] ] ; then
2008-06-02 22:44:07 +02:00
print is set
else
print is not set
fi
expected - stdout:
is set
expected - stderr - pattern:
/(# )*/
- - -
name: utf8opt - 2 b
description:
2008-12-04 19:11:08 +01:00
Check that the utf8 - mode flag is set at interactive startup
2009-06-08 00:43:46 +02:00
Expected failure if - DMKSH_ASSUME_UTF8 = 0
2008-07-10 23:25:00 +02:00
category: os:hpux
• 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-20 00:15:06 +02:00
arguments: ! - i !
2008-05-04 03:38:04 +02: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-20 00:15:06 +02:00
stdin:
2008-12-13 18:02:18 +01:00
if [ [ $- = * U * ] ] ; then
• 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-20 00:15:06 +02:00
print is set
else
print is not set
fi
expected - stdout:
is set
2008-05-10 05:16:07 +02: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-20 00:15:06 +02:00
- - -
2007-06-15 23:55:20 +02:00
name: aliases - 1
description:
Check if built - in shell aliases are okay
2009-07-25 22:52:41 +02:00
category: ! arge
2007-06-15 23:55:20 +02:00
stdin:
alias
typeset - f
expected - stdout:
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
integer = 'typeset -i'
local = typeset
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
2007-08-13 21:39:21 +02:00
source = 'PATH=$PATH:. command .'
2007-06-15 23:55:20 +02:00
stop = 'kill -STOP'
suspend = 'kill -STOP $$'
type = 'whence -v'
- - -
2009-07-25 22:52:41 +02:00
name: aliases - 1 - hartz4
description:
Check if built - in shell aliases are okay
category: arge
stdin:
alias
typeset - f
expected - stdout:
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
integer = 'typeset -i'
local = typeset
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
source = 'PATH=$PATH:. command .'
type = 'whence -v'
- - -
2008-02-25 01:58:26 +01:00
name: aliases - 2 a
2007-06-15 23:55:20 +02:00
description:
2007-06-17 02:50:09 +02:00
Check if “ set - o posix ” disables built - in aliases ( except a few )
2008-02-25 01:58:26 +01:00
category: disabled
2007-06-15 23:55:20 +02:00
arguments: ! - o ! posix !
stdin:
alias
typeset - f
2007-06-17 02:50:09 +02:00
expected - stdout:
integer = 'typeset -i'
local = typeset
2007-06-15 23:55:20 +02:00
- - -
2008-02-25 01:58:26 +01:00
name: aliases - 3 a
2007-06-15 23:55:20 +02:00
description:
2007-06-17 02:50:09 +02:00
Check if running as sh disables built - in aliases ( except a few )
2008-02-25 01:58:26 +01:00
category: disabled
arguments: ! - o ! posix !
stdin:
2008-04-01 18:01:45 +02:00
cp "$__progname" sh
2008-02-25 01:58:26 +01:00
. / sh - c 'alias; typeset -f'
rm - f sh
expected - stdout:
integer = 'typeset -i'
local = typeset
- - -
name: aliases - 2 b
description:
Check if “ set - o posix ” does not influence built - in aliases
2009-07-25 22:52:41 +02:00
category: ! arge
2008-02-25 01:58:26 +01:00
arguments: ! - o ! posix !
stdin:
alias
typeset - f
expected - stdout:
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
integer = 'typeset -i'
local = typeset
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
source = 'PATH=$PATH:. command .'
stop = 'kill -STOP'
suspend = 'kill -STOP $$'
type = 'whence -v'
- - -
name: aliases - 3 b
description:
Check if running as sh does not influence built - in aliases
2009-07-25 22:52:41 +02:00
category: ! arge
2007-06-15 23:55:20 +02:00
arguments: ! - o ! posix !
stdin:
2008-04-01 18:01:45 +02:00
cp "$__progname" sh
2007-06-15 23:55:20 +02:00
. / sh - c 'alias; typeset -f'
rm - f sh
2007-06-17 02:50:09 +02:00
expected - stdout:
2008-02-25 01:58:26 +01:00
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
2007-06-17 02:50:09 +02:00
integer = 'typeset -i'
local = typeset
2008-02-25 01:58:26 +01:00
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
source = 'PATH=$PATH:. command .'
stop = 'kill -STOP'
suspend = 'kill -STOP $$'
type = 'whence -v'
2007-06-15 23:55:20 +02:00
- - -
2009-07-25 22:52:41 +02:00
name: aliases - 2 b - hartz4
description:
Check if “ set - o posix ” does not influence built - in aliases
category: arge
arguments: ! - o ! posix !
stdin:
alias
typeset - f
expected - stdout:
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
integer = 'typeset -i'
local = typeset
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
source = 'PATH=$PATH:. command .'
type = 'whence -v'
- - -
name: aliases - 3 b - hartz4
description:
Check if running as sh does not influence built - in aliases
category: arge
arguments: ! - o ! posix !
stdin:
cp "$__progname" sh
. / sh - c 'alias; typeset -f'
rm - f sh
expected - stdout:
autoload = 'typeset -fu'
functions = 'typeset -f'
hash = 'alias -t'
history = 'fc -l'
integer = 'typeset -i'
local = typeset
login = 'exec login'
nohup = 'nohup '
r = 'fc -e -'
source = 'PATH=$PATH:. command .'
type = 'whence -v'
- - -
2009-07-06 17:06:25 +02:00
name: aliases - funcdef - 1
description:
Check if POSIX functions take precedences over aliases
stdin:
alias foo = 'echo makro'
foo ( ) {
echo funktion
}
foo
expected - stdout:
funktion
- - -
name: aliases - funcdef - 2
description:
Check if POSIX functions take precedences over aliases
stdin:
alias foo = 'echo makro'
foo ( ) {
echo funktion
}
foo
expected - stdout:
funktion
- - -
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
- - -
2007-06-23 01:34:42 +02: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 |
- - -
name: arrays - 2
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 |
- - -
2007-10-18 22:32:33 +02: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
print $ { foo [ * ] }
foo [ - 1 ] = f
print $ { foo [ 4294967295 ] } g $ { foo [ * ] }
expected - stdout:
a b c d e
f g a b c d e f
- - -
2007-06-28 01:12:59 +02: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
2007-07-06 03:30:32 +02:00
print a t $ { x:2:2 } $ { y:2:3 } $ { z:2:3 } a
2007-06-28 01:12:59 +02:00
print b $ { x:: 3 } $ { y:: 3 } $ { z:: 3 } b
print c $ { x:2: } $ { y:2: } $ { z:2: } c
print d $ { x:2 } $ { y:2 } $ { z:2 } d
print e $ { x:2:6 } $ { y:2:6 } $ { z:2:7 } e
print f $ { x:2:7 } $ { y:2:7 } $ { z:2:8 } f
print g $ { x:2:8 } $ { y:2:8 } $ { z:2:9 } g
expected - stdout:
2007-07-06 03:30:32 +02:00
a tcd 345 #75 a
2007-06-28 01:12:59 +02:00
b abc 123 16 # b
2007-07-06 03:37:39 +02:00
c c
2007-06-28 01:12:59 +02: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
print a $ { x: $ n:3 } $ { y: $ n:3 } $ { z: $ n:3 } a
2007-07-06 04:22:57 +02:00
print b $ { x: ( n ) : 3 } $ { y: ( n ) : 3 } $ { z: ( n ) : 3 } b
2007-06-28 01:12:59 +02:00
print c $ { x: ( - 2 ) : 1 } $ { y: ( - 2 ) : 1 } $ { z: ( - 2 ) : 1 } c
2007-07-06 04:22:57 +02:00
print d t $ { x: n:2 } $ { y: n:3 } $ { z: n:3 } d
2007-06-28 01:12:59 +02:00
expected - stdout:
a cde 345 #75 a
b cde 345 #75 b
c h 8 1 c
2007-07-06 04:22:57 +02:00
d tcd 345 #75 d
- - -
name: varexpand - substr - 3
description:
Check that some things that work in bash fail .
2007-07-06 13:54:34 +02:00
This is by design . And that some things fail in both .
2007-07-06 04:22:57 +02:00
stdin:
export x = abcdefghi n = 2
2009-07-19 13:14:28 +02: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'
"$__progname" - c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' > /dev/ null 2 > & 1 ; echo $?
2007-07-06 04:22:57 +02:00
expected - stdout:
vcdefghix
wcdefghix
zabcdefghix
2007-07-06 13:54:34 +02:00
1
2007-07-06 04:22:57 +02:00
expected - stderr - pattern:
/x:n.*bad substitution.*\n.*bad substitution/
2007-06-28 01:12:59 +02:00
- - -
2007-07-23 16:10:48 +02:00
name: varexpand - substr - 4
description:
Check corner cases for substring expansion
stdin:
x = abcdefghi
integer y = 2
print a $ { x: ( y == 1 ? 2 : 3 ) : 4 } a
expected - stdout:
a defg a
- - -
2009-05-16 17:53:02 +02:00
name: varexpand - substr - 5 A
description:
Check that substring expansions work on characters
stdin:
set + U
x = mäh
print a $ { x:: 1 } $ { x: - 1 } a
print b $ { x:: 3 } $ { x: - 3 } b
print c $ { x:1:2 } $ { x: - 3 : 2 } c
print d $ { #x} d
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
print a $ { x:: 1 } $ { x: - 1 } a
print b $ { x:: 2 } $ { x: - 2 } b
print c $ { x:1:1 } $ { x: - 2 : 1 } c
print d $ { #x} d
expected - stdout:
a m h a
b mä äh b
c ä ä c
d 3 d
- - -
2008-02-24 16:48:43 +01:00
name: print - funny - chars
description:
Check print builtin ' s capability to output designated characters
stdin:
print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
expected - stdout:
<d<> <64> Û€Û@>
- - -
2008-04-20 02:11:29 +02:00
name: print - nul - chars
description:
Check handling of NUL characters for print and read
note: second line should output “ 4 3 ” but we cannot
handle NUL characters in strings yet
stdin:
print $( ( $ ( print '<\0>' | wc - c ) ) )
x = $ ( print '<\0>' )
print $( ( $ ( print "$x" | wc - c ) ) ) $ { #x}
expected - stdout:
4
3 2
- - -
2008-02-24 16:57:20 +01:00
name: dot - needs - argument
description:
check Debian #415167 solution: '.' without arguments should fail
stdin:
2008-04-01 18:01:45 +02:00
"$__progname" - c .
"$__progname" - c source
2008-02-24 16:57:20 +01:00
expected - exit : e != 0
expected - stderr - pattern:
/\.: missing argument.*\n.*\.: missing argument/
- - -
2008-02-24 23:12:36 +01:00
name: alias - function - no - conflict
description:
make aliases not conflict with functions
note: for ksh - like functions , the order of preference is
different ; bash outputs baz instead of bar in line 2 below
stdin:
alias foo = 'echo bar'
foo ( ) {
echo baz
}
alias korn = 'echo bar'
function korn {
echo baz
}
foo
korn
unset - f foo
foo 2 > & - || echo rab
expected - stdout:
baz
bar
rab
- - -
• 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-20 00:15:06 +02:00
name: integer - base - one - 1
description:
check if the use of fake integer base 1 works
stdin:
2008-12-04 19:11:08 +01:00
set - U
• 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-20 00:15:06 +02:00
typeset - Uui16 i0 = 1 #<23> i1=1#€
typeset - i1 o0a = 64
typeset - i1 o1a = 0x263A
typeset - Uui1 o0b = 0x7E
typeset - Uui1 o1b = 0xFDD0
integer px = 0xCAFE 'p0=1# ' p1 = 1 #… pl=1#f
print "in <$i0> <$i1>"
print "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
typeset - Uui1 i0 i1
print "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
typeset - Uui16 tv1 = 1 #~ tv2=1# tv3=1#<23> tv4=1#<23> tv5=1#<23> tv6=1#<23> tv7=1# tv8=1#
print "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
typeset - i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
print "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
typeset - i1 xs1 = 0xEF7F xs2 = 0xEF80 xs3 = 0xFDD0
print "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
expected - stdout:
in <16#EFEF> <16#20AC>
out <@|~> <☺|>
pass <16#cafe> < 1 # > <1#…> <1#f> <<3C> |€>
specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
specW <~> < > <<3C> > <<3C> > <<3C> > <<3C> > < > < >
specU <> <<3C> > <>
- - -
name: integer - base - one - 2 a
description:
check if the use of fake integer base 1 stops at correct characters
stdin:
2008-12-04 19:11:08 +01:00
set - U
• 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-20 00:15:06 +02:00
integer x = 1 #foo
print /$x/
expected - stderr - pattern:
/1#foo: unexpected 'oo'/
expected - exit : e != 0
- - -
name: integer - base - one - 2 b
description:
check if the use of fake integer base 1 stops at correct characters
stdin:
2008-12-04 19:11:08 +01:00
set - U
• 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-20 00:15:06 +02:00
integer x = 1 #<23> <>
print /$x/
expected - stderr - pattern:
/1#<23> <> : unexpected '<27> '/
expected - exit : e != 0
- - -
name: integer - base - one - 2 c1
description:
check if the use of fake integer base 1 stops at correct characters
stdin:
2008-12-04 19:11:08 +01:00
set - U
• 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-20 00:15:06 +02:00
integer x = 1 #…
print /$x/
expected - stdout:
/1#…/
- - -
name: integer - base - one - 2 c2
description:
check if the use of fake integer base 1 stops at correct characters
stdin:
2008-12-04 19:11:08 +01:00
set + U
• 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-20 00:15:06 +02:00
integer x = 1 #…
print /$x/
expected - stderr - pattern:
/1#…: unexpected '<27> '/
expected - exit : e != 0
- - -
2008-04-20 03:12:52 +02:00
name: integer - base - one - 2 d1
description:
check if the use of fake integer base 1 handles octets okay
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23>
print /$x/ # invalid utf-8
expected - stdout:
/16#efff/
- - -
name: integer - base - one - 2 d2
description:
check if the use of fake integer base 1 handles octets
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23>
print /$x/ # invalid 2-byte
expected - stdout:
/16#efc2/
- - -
name: integer - base - one - 2 d3
description:
check if the use of fake integer base 1 handles octets
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23>
print /$x/ # invalid 2-byte
expected - stdout:
/16#efef/
- - -
name: integer - base - one - 2 d4
description:
check if the use of fake integer base 1 stops at invalid input
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23> <> <EFBFBD>
print /$x/ # invalid 3-byte
expected - stderr - pattern:
/1#<23> <> <EFBFBD> : unexpected '<27> '/
expected - exit : e != 0
- - -
name: integer - base - one - 2 d5
description:
check if the use of fake integer base 1 stops at invalid input
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23> <>
print /$x/ # non-minimalistic
expected - stderr - pattern:
/1#<23> <> : unexpected '<27> '/
expected - exit : e != 0
- - -
name: integer - base - one - 2 d6
description:
check if the use of fake integer base 1 stops at invalid input
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:12:52 +02:00
typeset - i16 x = 1 #<23> <> <EFBFBD>
print /$x/ # non-minimalistic
expected - stderr - pattern:
/1#<23> <> <EFBFBD> : unexpected '<27> '/
expected - exit : e != 0
- - -
2009-05-16 17:53:02 +02:00
name: integer - base - one - 3 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-20 00:15:06 +02:00
description:
some sample code for hexdumping
stdin:
2008-04-20 01:49:59 +02:00
{
print 'Hello, World!\\\nこんにちは! '
typeset - Uui16 i = 0x100
2008-04-20 02:11:29 +02:00
# change that to 0xFF once we can handle embedded
# NUL characters in strings / here documents
2008-04-20 01:49:59 +02:00
while ( ( i + + < 0x1FF ) ) ; do
print - n "\x${i#16#1}"
done
print
} | {
• 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-20 00:15:06 +02:00
typeset - Uui16 - Z11 pos = 0
typeset - Uui16 - Z5 hv
typeset - i1 wc = 0x0A
dasc =
nl = $ { wc #1#}
while IFS = read - r line ; do
line = $ line $ nl
while [ [ - n $ line ] ] ; do
hv = 1 #${line::1}
if ( ( ( pos & 15 ) == 0 ) ) ; then
( ( pos ) ) && print "$dasc|"
print - n "${pos#16#} "
dasc = ' |'
fi
print - n "${hv#16#} "
if ( ( ( hv < 32 ) || ( hv > 126 ) ) ) ; then
dasc = $ dasc .
else
dasc = $ dasc $ { line:: 1 }
fi
( ( ( pos + + & 15 ) == 7 ) ) && print - n - - '- '
line = $ { line:1 }
done
done
if ( ( ( pos & 15 ) != 1 ) ) ; then
while ( ( pos & 15 ) ) ; do
print - n ' '
( ( ( pos + + & 15 ) == 7 ) ) && print - n - - '- '
done
print "$dasc|"
fi
}
expected - stdout:
00000000 48 65 6 C 6 C 6 F 2 C 20 57 - 6 F 72 6 C 64 21 5 C 0 A E3 | Hello , World ! \ .. |
00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC | ... ... ... ... ... . |
2008-04-20 01:49:59 +02:00
00000020 81 0 A 01 02 03 04 05 06 - 07 08 09 0 A 0 B 0 C 0 D 0 E | ... ... ... ... ... . |
00000030 0 F 10 11 12 13 14 15 16 - 17 18 19 1 A 1 B 1 C 1 D 1 E | ... ... ... ... ... . |
00000040 1 F 20 21 22 23 24 25 26 - 27 28 29 2 A 2 B 2 C 2 D 2 E | . ! " #$%&'()*+,-.|
00000050 2 F 30 31 32 33 34 35 36 - 37 38 39 3 A 3 B 3 C 3 D 3 E | / 01234567 89 : ; <=> |
00000060 3 F 40 41 42 43 44 45 46 - 47 48 49 4 A 4 B 4 C 4 D 4 E | ? @ ABCDEFGHIJKLMN |
00000070 4 F 50 51 52 53 54 55 56 - 57 58 59 5 A 5 B 5 C 5 D 5 E | OPQRSTUVWXYZ [ \ ] ^ |
000000 80 5 F 60 61 62 63 64 65 66 - 67 68 69 6 A 6 B 6 C 6 D 6 E | _ ` abcdefghijklmn |
000000 90 6 F 70 71 72 73 74 75 76 - 77 78 79 7 A 7 B 7 C 7 D 7 E | opqrstuvwxyz { | } ~ |
000000 A0 7 F 80 81 82 83 84 85 86 - 87 88 89 8 A 8 B 8 C 8 D 8 E | ... ... ... ... ... . |
000000 B0 8 F 90 91 92 93 94 95 96 - 97 98 99 9 A 9 B 9 C 9 D 9 E | ... ... ... ... ... . |
000000 C0 9 F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE | ... ... ... ... ... . |
000000 D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE | ... ... ... ... ... . |
000000 E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE | ... ... ... ... ... . |
000000 F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE | ... ... ... ... ... . |
00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE | ... ... ... ... ... . |
00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE | ... ... ... ... ... . |
00000120 FF 0 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-20 00:15:06 +02:00
- - -
2009-05-16 17:53:02 +02:00
name: integer - base - one - 3 W
2008-04-20 03:23:49 +02:00
description:
some sample code for hexdumping Unicode
stdin:
2008-12-04 19:11:08 +01:00
set - U
2008-04-20 03:23:49 +02:00
{
print 'Hello, World!\\\nこんにちは! '
typeset - Uui16 i = 0x100
# change that to 0xFF once we can handle embedded
# NUL characters in strings / here documents
while ( ( i + + < 0x1FF ) ) ; do
print - n "\u${i#16#1}"
done
print
print \ \ xff # invalid utf-8
print \ \ xc2 # invalid 2-byte
print \ \ xef \ \ xbf \ \ xc0 # invalid 3-byte
print \ \ xc0 \ \ x80 # non-minimalistic
print \ \ xe0 \ \ x80 \ \ x80 # non-minimalistic
print '<27> ' # end of range
} | {
typeset - Uui16 - Z11 pos = 0
2009-05-16 17:53:02 +02:00
typeset - Uui16 - Z7 hv
2008-04-20 03:23:49 +02:00
typeset - i1 wc = 0x0A
2009-05-16 18:03:41 +02:00
typeset - i lpos
2008-04-20 03:23:49 +02:00
dasc =
nl = $ { wc #1#}
while IFS = read - r line ; do
line = $ line $ nl
2009-05-16 18:03:41 +02:00
lpos = 0
while ( ( lpos < $ { #line} )); do
wc = 1 #${line:(lpos++):1}
2008-04-20 03:23:49 +02:00
if ( ( ( wc < 32 ) || \
( ( wc > 126 ) && ( wc < 160 ) ) ) ) ; then
dch = .
elif ( ( ( wc & 0xFF80 ) == 0xEF80 ) ) ; then
dch = <EFBFBD>
else
dch = $ { wc #1#}
fi
2009-05-16 18:03:41 +02:00
if ( ( ( pos & 7 ) == 7 ) ) ; then
2008-04-20 03:23:49 +02:00
dasc = $ dasc $ dch
dch =
2009-05-16 18:03:41 +02:00
elif ( ( ( pos & 7 ) == 0 ) ) ; then
2009-05-16 17:53:02 +02:00
( ( pos ) ) && print "$dasc|"
print - n "${pos#16#} "
dasc = ' |'
fi
let hv = wc
print - n "${hv#16#} "
( ( ( pos + + & 7 ) == 3 ) ) && \
print - n - - '- '
2008-04-20 03:23:49 +02:00
dasc = $ dasc $ dch
done
done
2009-05-16 17:53:02 +02:00
if ( ( pos & 7 ) ) ; then
while ( ( pos & 7 ) ) ; do
print - n ' '
( ( ( pos + + & 7 ) == 3 ) ) && print - n - - '- '
2008-04-20 03:23:49 +02:00
done
print "$dasc|"
fi
}
expected - stdout:
2009-05-16 17:53:02 +02:00
00000000 004 8 0065 006 C 006 C - 006 F 002 C 0020 0057 | Hello , W |
0000000 8 006 F 0072 006 C 0064 - 0021 005 C 000 A 3053 | orld ! \ . こ |
00000010 3093 306 B 3061 306 F - FF01 000 A 0001 0002 | んにちは ! ... |
0000001 8 0003 0004 0005 0006 - 0007 000 8 000 9 000 A | ... ... .. |
00000020 000 B 000 C 000 D 000 E - 000 F 0010 0011 0012 | ... ... .. |
0000002 8 0013 0014 0015 0016 - 0017 001 8 001 9 001 A | ... ... .. |
00000030 001 B 001 C 001 D 001 E - 001 F 0020 0021 0022 | ... .. ! " |
0000003 8 0023 0024 0025 0026 - 0027 002 8 002 9 002 A | #$%&'()*|
00000040 002 B 002 C 002 D 002 E - 002 F 0030 0031 0032 | + , - . / 012 |
0000004 8 0033 0034 0035 0036 - 0037 003 8 003 9 003 A | 3456789 : |
00000050 003 B 003 C 003 D 003 E - 003 F 0040 0041 0042 | ; <=> ? @ AB |
0000005 8 0043 0044 0045 0046 - 0047 004 8 004 9 004 A | CDEFGHIJ |
00000060 004 B 004 C 004 D 004 E - 004 F 0050 0051 0052 | KLMNOPQR |
0000006 8 0053 0054 0055 0056 - 0057 005 8 005 9 005 A | STUVWXYZ |
00000070 005 B 005 C 005 D 005 E - 005 F 0060 0061 0062 | [ \ ] ^ _ ` ab |
0000007 8 0063 0064 0065 0066 - 0067 006 8 006 9 006 A | cdefghij |
000000 80 006 B 006 C 006 D 006 E - 006 F 0070 0071 0072 | klmnopqr |
000000 88 0073 0074 0075 0076 - 0077 007 8 007 9 007 A | stuvwxyz |
000000 90 007 B 007 C 007 D 007 E - 007 F 00 80 00 81 00 82 | { | } ~ ... . |
000000 98 00 83 00 84 00 85 00 86 - 00 87 00 88 00 89 00 8 A | ... ... .. |
000000 A0 00 8 B 00 8 C 00 8 D 00 8 E - 00 8 F 00 90 00 91 00 92 | ... ... .. |
000000 A8 00 93 00 94 00 95 00 96 - 00 97 00 98 00 99 00 9 A | ... ... .. |
000000 B0 00 9 B 00 9 C 00 9 D 00 9 E - 00 9 F 00 A0 00 A1 00 A2 | ... .. ¡ ¢ |
000000 B8 00 A3 00 A4 00 A5 00 A6 - 00 A7 00 A8 00 A9 00 AA | £ ¤ ¥ ¦ § ¨ © ª |
000000 C0 00 AB 00 AC 00 AD 00 AE - 00 AF 00 B0 00 B1 00 B2 | « ¬ ® ¯ ° ± ² |
000000 C8 00 B3 00 B4 00 B5 00 B6 - 00 B7 00 B8 00 B9 00 BA | ³ ´ µ ¶ · ¸ ¹ º |
000000 D0 00 BB 00 BC 00 BD 00 BE - 00 BF 00 C0 00 C1 00 C2 | » ¼ ½ ¾ ¿ ÀÁÂ |
000000 D8 00 C3 00 C4 00 C5 00 C6 - 00 C7 00 C8 00 C9 00 CA | ÃÄÅÆÇÈÉÊ |
000000 E0 00 CB 00 CC 00 CD 00 CE - 00 CF 00 D0 00 D1 00 D2 | ËÌÍÎÏÐÑÒ |
000000 E8 00 D3 00 D4 00 D5 00 D6 - 00 D7 00 D8 00 D9 00 DA | ÓÔÕÖ × ØÙÚ |
000000 F0 00 DB 00 DC 00 DD 00 DE - 00 DF 00 E0 00 E1 00 E2 | ÛÜÝÞßàáâ |
000000 F8 00 E3 00 E4 00 E5 00 E6 - 00 E7 00 E8 00 E9 00 EA | ãäåæçèéê |
00000100 00 EB 00 EC 00 ED 00 EE - 00 EF 00 F0 00 F1 00 F2 | ëìíîïðñò |
0000010 8 00 F3 00 F4 00 F5 00 F6 - 00 F7 00 F8 00 F9 00 FA | óôõö ÷ øùú |
00000110 00 FB 00 FC 00 FD 00 FE - 00 FF 000 A EFFF 000 A | ûüýþÿ . <EFBFBD> . |
0000011 8 EFC2 000 A EFEF EFBF - EFC0 000 A EFC0 EF80 | <EFBFBD> . <EFBFBD> <EFBFBD> <EFBFBD> . <EFBFBD> <EFBFBD> |
00000120 000 A EFE0 EF80 EF80 - 000 A FFFD EFEF EFBF | . <EFBFBD> <EFBFBD> <EFBFBD> . <EFBFBD> <EFBFBD> <EFBFBD> |
0000012 8 EFBE EFEF EFBF EFBF - 000 A | <EFBFBD> <EFBFBD> <EFBFBD> <EFBFBD> . |
2008-04-20 03:23:49 +02:00
- - -
2008-04-20 23:30:29 +02:00
name: ulimit - 1
description:
Check if we can use a specific syntax idiom for ulimit
stdin:
if ! x = $ ( ulimit - d ) ; then
print expected to fail on this OS
else
ulimit - dS $ x && print okay
fi
expected - stdout:
okay
- - -
2008-06-29 00:51:56 +02:00
name: bashiop - 1
description:
Check if GNU bash - like I / O redirection works
Part 1 : this is also supported by GNU bash
stdin:
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout & > foo
echo ===
cat foo
expected - stdout:
tri
===
ras
dwa
- - -
name: bashiop - 2 a
description:
Check if GNU bash - like I / O redirection works
Part 2 : this is * not * supported by GNU bash
stdin:
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout 3 & > foo
echo ===
cat foo
expected - stdout:
ras
===
dwa
tri
- - -
name: bashiop - 2 b
description:
Check if GNU bash - like I / O redirection works
Part 2 : this is * not * supported by GNU bash
stdin:
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout 3 > foo & > & 3
echo ===
cat foo
expected - stdout:
===
ras
dwa
tri
- - -
name: bashiop - 2 c
description:
Check if GNU bash - like I / O redirection works
2009-07-19 13:14:28 +02:00
Part 2 : this is supported by GNU bash 4 only
2008-06-29 00:51:56 +02:00
stdin:
echo mir > foo
set - o noclobber
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout & >> foo
echo ===
cat foo
expected - stdout:
tri
===
mir
ras
dwa
- - -
name: bashiop - 3 a
description:
Check if GNU bash - like I / O redirection fails correctly
Part 1 : this is also supported by GNU bash
stdin:
echo mir > foo
set - o noclobber
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout & > foo
echo ===
cat foo
expected - stdout:
===
mir
expected - stderr - pattern: /.*: cannot (create|overwrite) .*/
- - -
name: bashiop - 3 b
description:
Check if GNU bash - like I / O redirection fails correctly
Part 2 : this is * not * supported by GNU bash
stdin:
echo mir > foo
set - o noclobber
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
threeout & > | foo
echo ===
cat foo
expected - stdout:
tri
===
ras
dwa
- - -
2008-11-30 17:53:15 +01:00
name: bashiop - 4
description:
Check if GNU bash - like I / O redirection works
Part 4 : this is also supported by GNU bash ,
but failed in some mksh versions
stdin:
exec 3 > & 1
function threeout {
echo ras
echo dwa > & 2
echo tri > & 3
}
2008-11-30 17:57:40 +01:00
function blubb {
[ [ - e bar ] ] && threeout "$bf" & > foo
}
blubb
2008-11-30 17:53:15 +01:00
echo - n > bar
2008-11-30 17:57:40 +01:00
blubb
2008-11-30 17:53:15 +01:00
echo ===
cat foo
expected - stdout:
tri
===
ras
dwa
- - -
2008-07-09 23:32:45 +02:00
name: mkshiop - 1
description:
Check for support of more than 9 file descriptors
2009-04-06 10:33:37 +02:00
category: ! convfds
2008-07-09 23:32:45 +02:00
stdin:
read - u10 foo 10 << < bar
print x $ foo
expected - stdout:
xbar
- - -
name: mkshiop - 2
description:
Check for support of more than 9 file descriptors
2009-04-06 10:33:37 +02:00
category: ! convfds
2008-07-09 23:32:45 +02:00
stdin:
exec 12 > foo
print - u12 bar
print baz > & 12
cat foo
expected - stdout:
bar
baz
- - -
2008-07-17 14:57:59 +02:00
name: oksh - shcrash
description:
src /regress/ bin /ksh/s hcrash . sh , v 1.1
stdin:
deplibs = " - lz - lpng /usr/ local /lib/ libjpeg . la - ltiff - lm - lX11 - lXext /usr/ local /lib/ libiconv . la - L /usr/ local /lib -L/ usr /ports/ devel /gettext/ w - gettext - 0.10 .40 /gettext-0.10.40/i ntl /.libs / usr /local/ lib /libintl.la / usr /local/ lib /libglib.la / usr /local/ lib /libgmodule.la -lintl -lm -lX11 -lXext -L/ usr /X11R6/ lib - lglib - lgmodule - L /usr/ local /lib / usr /local/ lib /libgdk.la -lintl -lm -lX11 -lXext -L/ usr /X11R6/ lib - lglib - lgmodule - L /usr/ local /lib / usr /local/ lib /libgtk.la -ltiff -ljpeg -lz -lpng -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/ usr /X11R6/ lib - lglib - lgmodule - L /usr/ local /lib / usr /local/ lib /libgdk_pixbuf.la -lz -lpng / usr /local/ lib /libiconv.la -L/ usr /local/ lib - L /usr/ ports /devel/g ettext /w-gettext-0.10.40/g ettext - 0.10 .40 /intl/ . libs /usr/ local /lib/ libintl . la /usr/ local /lib/ libglib . la - lm - lm /usr/ local /lib/ libaudiofile . la - lm - lm - laudiofile - L /usr/ local /lib / usr /local/ lib /libesd.la -lm -lz -L/ usr /local/ lib /usr/ local /lib/ libgnomesupport . la - lm - lz - lm - lglib - L /usr/ local /lib / usr /local/ lib /libgnome.la -lX11 -lXext / usr /local/ lib /libiconv.la -L/ usr /local/ lib - L /usr/ ports /devel/g ettext /w-gettext-0.10.40/g ettext - 0.10 .40 /intl/ . libs /usr/ local /lib/ libintl . la /usr/ local /lib/ libgmodule . la - lintl - lm - lX11 - lXext - L /usr/ X11R6 /lib -lglib -lgmodule -L/ usr /local/ lib /usr/ local /lib/ libgdk . la - lintl - lm - lX11 - lXext - L /usr/ X11R6 /lib -lglib -lgmodule -L/ usr /local/ lib /usr/ local /lib/ libgtk . la - lICE - lSM - lz - lpng /usr/ local /lib/ libungif . la /usr/ local /lib/ libjpeg . la - ltiff - lm - lz - lpng /usr/ local /lib/ libungif . la - lz /usr/ local /lib/ libjpeg . la - ltiff - L /usr/ local /lib -L/ usr /X11R6/ lib /usr/ local /lib/ libgdk_imlib . la - lm - L /usr/ local /lib / usr /local/ lib /libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/ usr /X11R6/ lib - lm - lz - lpng - lungif - lz - ljpeg - ltiff - ljpeg - lgdk_imlib - lglib - lm - laudiofile - lm - laudiofile - lesd - L /usr/ local /lib / usr /local/ lib /libgnomeui.la -lz -lz / usr /local/ lib /libxml.la -lz -lz -lz / usr /local/ lib /libxml.la -lm -lX11 -lXext / usr /local/ lib /libiconv.la -L/ usr /ports/ devel /gettext/ w - gettext - 0.10 .40 /gettext-0.10.40/i ntl /.libs / usr /local/ lib /libintl.la / usr /local/ lib /libglib.la / usr /local/ lib /libgmodule.la -lintl -lglib -lgmodule / usr /local/ lib /libgdk.la / usr /local/ lib /libgtk.la -L/ usr /X11R6/ lib - L /usr/ local /lib / usr /local/ lib /libglade.la -lz -lz -lz / usr /local/ lib /libxml.la / usr /local/ lib /libglib.la -lm -lm / usr /local/ lib /libaudiofile.la -lm -lm -laudiofile / usr /local/ lib /libesd.la -lm -lz / usr /local/ lib /libgnomesupport.la -lm -lz -lm -lglib / usr /local/ lib /libgnome.la -lX11 -lXext / usr /local/ lib /libiconv.la -L/ usr /ports/ devel /gettext/ w - gettext - 0.10 .40 /gettext-0.10.40/i ntl /.libs / usr /local/ lib /libintl.la / usr /local/ lib /libgmodule.la -lintl -lm -lX11 -lXext -lglib -lgmodule / usr /local/ lib /libgdk.la -lintl -lm -lX11 -lXext -lglib -lgmodule / usr /local/ lib /libgtk.la -lICE -lSM -lz -lpng / usr /local/ lib /libungif.la / usr /local/ lib /libjpeg.la -ltiff -lm -lz -lz / usr /local/ lib /libgdk_imlib.la / usr /local/ lib /libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lz -lungif -lz -ljpeg -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd / usr /local/ lib /libgnomeui.la -L/ usr /X11R6/ lib - L /usr/ local /lib / usr /local/ lib /libglade-gnome.la / usr /local/ lib /libglib.la -lm -lm / usr /local/ lib /libaudiofile.la -lm -lm -laudiofile -L/ usr /local/ lib /usr/ local /lib/ libesd . la - lm - lz - L /usr/ local /lib / usr /local/ lib /libgnomesupport.la -lm -lz -lm -lglib -L/ usr /local/ lib /usr/ local /lib/ libgnome . la - lX11 - lXext /usr/ local /lib/ libiconv . la - L /usr/ local /lib -L/ usr /ports/ devel /gettext/ w - gettext - 0.10 .40 /gettext-0.10.40/i ntl /.libs / usr /local/ lib /libintl.la / usr /local/ lib /libgmodule.la -lintl -lm -lX11 -lXext -L/ usr /X11R6/ lib - lglib - lgmodule - L /usr/ local /lib / usr /local/ lib /libgdk.la -lintl -lm -lX11 -lXext -L/ usr /X11R6/ lib - lglib - lgmodule - L /usr/ local /lib / usr /local/ lib /libgtk.la -lICE -lSM -lz -lpng / usr /local/ lib /libungif.la / usr /local/ lib / libjpeg . la - ltiff - lm - lz - lp
specialdeplibs = "-lgnomeui -lart_lgpl -lgdk_imlib -ltiff -ljpeg -lungif -lpng -lz -lSM -lICE -lgtk -lgdk -lgmodule -lintl -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -lglib"
for deplib in $ deplibs ; do
case $ deplib in
- L * )
new_libs = "$deplib $new_libs"
; ;
* )
case " $specialdeplibs " in
* " $deplib " * )
new_libs = "$deplib $new_libs" ; ;
esac
; ;
esac
done
- - -
name: oksh - varfunction
description:
$ OpenBSD: varfunction . sh , v 1.1 2003 /12/ 15 05 : 28 : 40 otto Exp $
Calling
FOO = bar f
where f is a ksh style function , should not set FOO in the current
env . If f is a bourne style function , FOO should be set . Furthermore ,
the function should receive a correct value of FOO . Additionally ,
setting FOO in the function itself should not change the value in
global environment .
Inspired by PR 2450 .
stdin:
function k {
if [ x $ FOO != xbar ] ; then
echo 1
return 1
fi
x = $ ( env | grep FOO )
if [ "x$x" != "xFOO=bar" ] ; then
echo 2
return 1 ;
fi
FOO = foo
return 0
}
b ( ) {
if [ x $ FOO != xbar ] ; then
echo 3
return 1
fi
x = $ ( env | grep FOO )
if [ "x$x" != "xFOO=bar" ] ; then
echo 4
return 1 ;
fi
FOO = foo
return 0
}
FOO = bar k
if [ $? != 0 ] ; then
exit 1
fi
if [ x $ FOO != x ] ; then
exit 1
fi
FOO = bar b
if [ $? != 0 ] ; then
exit 1
fi
if [ x $ FOO != xbar ] ; then
exit 1
fi
FOO = barbar
FOO = bar k
if [ $? != 0 ] ; then
exit 1
fi
if [ x $ FOO != xbarbar ] ; then
exit 1
fi
FOO = bar b
if [ $? != 0 ] ; then
exit 1
fi
if [ x $ FOO != xbar ] ; then
exit 1
fi
- - -
2008-09-17 21:31:30 +02:00
name: fd - cloexec - 1
description:
Verify that file descriptors > 2 are private for Korn shells
file - setup: file 644 "test.sh"
print - u3 Fowl
stdin:
exec 3 > & 1
"$__progname" test . sh
expected - exit : e != 0
expected - stderr:
test . sh [ 1 ] : print : - u: 3 : bad file descriptor
- - -
name: fd - cloexec - 2
description:
Verify that file descriptors > 2 are not private for POSIX shells
See Debian Bug #154540, Closes: #499139
file - setup: file 644 "test.sh"
print - u3 Fowl
stdin:
set - o posix
exec 3 > & 1
"$__progname" test . sh
expected - stdout:
Fowl
- - -
2009-04-22 18:43:18 +02:00
name: comsub - 1
description:
COMSUB are currently parsed by hacking lex . c instead of
recursively ( see regression - 6 ) : matching parenthesēs bug
Fails on: pdksh mksh bash2 bash3 zsh
2009-07-19 13:14:28 +02:00
Passes on: bash4 ksh93
2009-04-22 18:43:18 +02:00
expected - fail: yes
stdin:
echo $ ( case 1 in ( 1 ) echo yes ; ; ( 2 ) echo no ; ; esac )
echo $ ( case 1 in 1 ) echo yes ; ; 2 ) echo no ; ; esac )
expected - stdout:
yes
yes
- - -
name: comsub - 2
description:
RedHat BZ #496791 – another case of missing recursion
in parsing COMSUB expressions
2009-07-19 13:14:28 +02:00
Fails on: pdksh mksh bash2 bash3 ¹ bash4 ¹ zsh
2009-04-22 18:43:18 +02:00
Passes on: ksh93
2009-07-19 13:14:28 +02:00
① bash [ 34 ] seem to choke on comment ending with backslash - newline
2009-04-22 18:43:18 +02:00
expected - fail: yes
stdin:
# a comment with " ' \
x = $(
echo yes
# a comment with " ' \
)
echo $ x
expected - stdout:
yes
- - -
2009-05-21 16:28:35 +02: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
- - -
2009-05-27 21:52:38 +02:00
name: event - subst - 1 a
description:
Check that '!' substitution in interactive mode works
file - setup: file 755 "falsetto"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo molto bene
exit 42
file - setup: file 755 "!false"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo si
arguments: ! - i !
stdin:
export PATH = . : $ PATH
falsetto
echo yeap
! false
expected - exit : 42
expected - stdout:
molto bene
yeap
molto bene
expected - stderr - pattern:
/.*/
- - -
name: event - subst - 1 b
description:
Check that '!' substitution in interactive mode works
even when a space separates it from the search command ,
which is not what GNU bash provides but required for the
other regression tests below to check
file - setup: file 755 "falsetto"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo molto bene
exit 42
file - setup: file 755 "!"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo si
arguments: ! - i !
stdin:
export PATH = . : $ PATH
falsetto
echo yeap
! false
expected - exit : 42
expected - stdout:
molto bene
yeap
molto bene
expected - stderr - pattern:
/.*/
- - -
name: event - subst - 2
description:
Check that '!' substitution in interactive mode
does not break things
file - setup: file 755 "falsetto"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo molto bene
exit 42
file - setup: file 755 "!"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo si
arguments: ! - i !
env - setup: ! ENV = . / Env !
file - setup: file 644 "Env"
PS1 = X
stdin:
export PATH = . : $ PATH
falsetto
echo yeap
! false
echo meow
! false
echo = $?
if
! false ; then echo foo ; else echo bar ; fi
expected - stdout:
molto bene
yeap
molto bene
meow
molto bene
= 42
foo
expected - stderr - pattern:
/.*/
- - -
name: event - subst - 3
description:
Check that '!' substitution in noninteractive mode is ignored
file - setup: file 755 "falsetto"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo molto bene
exit 42
file - setup: file 755 "!false"
2009-06-06 16:23:17 +02:00
#! /bin/sh
2009-05-27 21:52:38 +02:00
echo si
stdin:
export PATH = . : $ PATH
falsetto
echo yeap
! false
echo meow
! false
echo = $?
if
! false ; then echo foo ; else echo bar ; fi
expected - stdout:
molto bene
yeap
si
meow
= 0
foo
- - -
2009-07-16 17:06:45 +02:00
name: nounset - 1
description:
Check that "set -u" matches ( future ) POSIX requirement
stdin:
( set - u
try ( ) {
local v
eval v = \ $$ 1
if [ [ - n $ v ] ] ; then
echo $ 1 = nz
else
echo $ 1 = zf
fi
}
x = y
( echo $ x )
echo = 1
( echo $ y )
echo = 2
( try x )
echo = 3
( try y )
echo = 4
( try 0 )
echo = 5
( try 2 )
echo = 6
( try )
echo = 7
( echo at = $@ )
echo = 8
( echo asterisk = $* )
echo = 9
( echo $? )
echo = 10
( echo $! )
echo = 11
( echo $- )
echo = 12
#(echo $_)
#echo =13
( echo $# )
echo = 14
( mypid = $$ ; try mypid )
echo = 15
) 2 > & 1 | sed - e 's/^[^]]*]//' - e 's/^[^:]*: *//'
expected - stdout:
y
= 1
y: parameter not set
= 2
x = nz
= 3
y: parameter not set
= 4
0 = nz
= 5
2 : parameter not set
= 6
1 : parameter not set
= 7
at =
= 8
asterisk =
= 9
0
= 10
! : parameter not set
= 11
ush
= 12
0
= 14
mypid = nz
= 15
- - -