a34b05d2e6
This opens an OpenBSD-mirabile (aka MirBSD) repository. ### MirBSD is: # Copyright (c) 1982-2003 by Thorsten "mirabile" Glaser <x86@ePost.de> # Copyright © 1968-2003 The authors of And contributors to UNIX®, the # C Language, BSD/Berkeley Unix; 386BSD, NetBSD 1.1 and OpenBSD. # # Anyone who obtained a copy of this work is hereby permitted to freely use, # distribute, modify, merge, sublicence, give away or sell it as long as the # authors are given due credit and the following notice is retained: # # This work is provided "as is", with no explicit or implicit warranty what- # soever. Use it only at your own risk. In no event may an author or contri- # butor be held liable for any damage, directly or indirectly, that origina- # ted through or is caused by creation or modification of this work. MirBSD is my private tree. MirBSD does not differ very much from OpenBSD and intentionally tracks OpenBSD. That's why it _is_ OpenBSD, just not the official one. It's like with DarrenBSD. At time of this writing, no advertising for MirBSD must be done, because the advertising clause has not yet been sorted out. http://templeofhate.com/tglaser/MirBSD/index.php
342 lines
4.2 KiB
Raku
342 lines
4.2 KiB
Raku
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
|
|
|
|
#
|
|
# These tests deal with how \newline is handled in various situations. The
|
|
# first group of tests are places where it shouldn't be collapsed, the next
|
|
# group of tests are places where it should be collapsed.
|
|
#
|
|
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
|
|
---
|
|
|
|
name: blsk-nl-ign-4
|
|
description:
|
|
Check interaction of aliases, single quotes and here-documents
|
|
with backslash-newline
|
|
(don't know what posix has to say about this)
|
|
stdin:
|
|
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
|
|
---
|
|
|
|
name: blsk-nl-ign-5
|
|
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
|
|
---
|
|
|
|
name: blsk-nl-9
|
|
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)
|
|
stdin:
|
|
alias x='echo hi\'
|
|
x
|
|
echo there
|
|
expected-stdout:
|
|
hiecho there
|
|
---
|
|
|
|
name: blsk-nl-10
|
|
description:
|
|
Check that \newline in a keyword is collapsed
|
|
stdin:
|
|
i\
|
|
f true; then\
|
|
echo pass; el\
|
|
se echo fail; fi
|
|
expected-stdout:
|
|
pass
|
|
---
|
|
|
|
#
|
|
# Places \newline should be collapsed (ksh extensions)
|
|
#
|
|
|
|
name: blsk-nl-ksh-1
|
|
description:
|
|
Check that \newline is collapsed in extended globbing
|
|
(ksh93 fails this)
|
|
stdin:
|
|
xxx=foo
|
|
case $xxx in
|
|
(f*\
|
|
(\
|
|
o\
|
|
)\
|
|
) echo ok ;;
|
|
*) echo bad
|
|
esac
|
|
expected-stdout:
|
|
ok
|
|
---
|
|
|
|
name: blsk-nl-ksh-2
|
|
description:
|
|
Check that \newline is collapsed in ((...)) expressions
|
|
(ksh93 fails this)
|
|
stdin:
|
|
i=1
|
|
(\
|
|
(\
|
|
i=i+2\
|
|
)\
|
|
)
|
|
echo $i
|
|
expected-stdout:
|
|
3
|
|
---
|
|
|