153f60528SJilles Tjoelker# POSIX leaves the effect of NUL bytes in command substitution output 253f60528SJilles Tjoelker# unspecified but we have always discarded them. 353f60528SJilles Tjoelker 453f60528SJilles Tjoelkerfailures=0 553f60528SJilles Tjoelker 653f60528SJilles Tjoelkercheck() { 753f60528SJilles Tjoelker if [ "$2" != "$3" ]; then 853f60528SJilles Tjoelker printf "Failed at line %s: got \"%s\" expected \"%s\"\n" "$1" "$2" "$3" 953f60528SJilles Tjoelker : $((failures += 1)) 1053f60528SJilles Tjoelker fi 1153f60528SJilles Tjoelker} 1253f60528SJilles Tjoelker 1353f60528SJilles Tjoelkerfmt='\0a\0 \0b\0c d\0' 1453f60528SJilles Tjoelkerassign_builtin=$(printf "$fmt") 1553f60528SJilles Tjoelkercheck "$LINENO" "$assign_builtin" "a bc d" 1653f60528SJilles Tjoelkerassign_pipeline=$(printf "$fmt" | cat) 1753f60528SJilles Tjoelkercheck "$LINENO" "$assign_pipeline" "a bc d" 1853f60528SJilles Tjoelkerset -- $(printf "$fmt") $(printf "$fmt" | cat) "$(printf "$fmt")" "$(printf "$fmt" | cat)" 1953f60528SJilles TjoelkerIFS=@ 2053f60528SJilles Tjoelkersplits="$*" 2153f60528SJilles Tjoelkercheck "$LINENO" "$splits" "a@bc@d@a@bc@d@a bc d@a bc d" 2253f60528SJilles Tjoelker 2353f60528SJilles Tjoelker[ "$failures" = 0 ] 24