]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - bin/sh/tests/expansion/cmdsubst24.0
Import libxo-0.7.2; add xo_options.7.
[FreeBSD/FreeBSD.git] / bin / sh / tests / expansion / cmdsubst24.0
1 # $FreeBSD$
2 # POSIX leaves the effect of NUL bytes in command substitution output
3 # unspecified but we have always discarded them.
4
5 failures=0
6
7 check() {
8         if [ "$2" != "$3" ]; then
9                 printf "Failed at line %s: got \"%s\" expected \"%s\"\n" "$1" "$2" "$3"
10                 : $((failures += 1))
11         fi
12 }
13
14 fmt='\0a\0 \0b\0c d\0'
15 assign_builtin=$(printf "$fmt")
16 check "$LINENO" "$assign_builtin" "a bc d"
17 assign_pipeline=$(printf "$fmt" | cat)
18 check "$LINENO" "$assign_pipeline" "a bc d"
19 set -- $(printf "$fmt") $(printf "$fmt" | cat) "$(printf "$fmt")" "$(printf "$fmt" | cat)" 
20 IFS=@
21 splits="$*"
22 check "$LINENO" "$splits" "a@bc@d@a@bc@d@a bc d@a bc d"
23
24 [ "$failures" = 0 ]