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
5failures=0
6
7check() {
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
14fmt='\0a\0 \0b\0c d\0'
15assign_builtin=$(printf "$fmt")
16check "$LINENO" "$assign_builtin" "a bc d"
17assign_pipeline=$(printf "$fmt" | cat)
18check "$LINENO" "$assign_pipeline" "a bc d"
19set -- $(printf "$fmt") $(printf "$fmt" | cat) "$(printf "$fmt")" "$(printf "$fmt" | cat)"
20IFS=@
21splits="$*"
22check "$LINENO" "$splits" "a@bc@d@a@bc@d@a bc d@a bc d"
23
24[ "$failures" = 0 ]
25