]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/expansion/cmdsubst24.0
shell_cmds-216.60.1.tar.gz
[apple/shell_cmds.git] / sh / tests / expansion / cmdsubst24.0
1 # $FreeBSD: head/bin/sh/tests/expansion/cmdsubst24.0 317347 2017-04-23 21:58:17Z jilles $
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 ]