1*53f60528SJilles Tjoelker# POSIX leaves the effect of NUL bytes in command substitution output 2*53f60528SJilles Tjoelker# unspecified but we have always discarded them. 3*53f60528SJilles Tjoelker 4*53f60528SJilles Tjoelkerfailures=0 5*53f60528SJilles Tjoelker 6*53f60528SJilles Tjoelkercheck() { 7*53f60528SJilles Tjoelker if [ "$2" != "$3" ]; then 8*53f60528SJilles Tjoelker printf "Failed at line %s: got \"%s\" expected \"%s\"\n" "$1" "$2" "$3" 9*53f60528SJilles Tjoelker : $((failures += 1)) 10*53f60528SJilles Tjoelker fi 11*53f60528SJilles Tjoelker} 12*53f60528SJilles Tjoelker 13*53f60528SJilles Tjoelkerfmt='\0a\0 \0b\0c d\0' 14*53f60528SJilles Tjoelkerassign_builtin=$(printf "$fmt") 15*53f60528SJilles Tjoelkercheck "$LINENO" "$assign_builtin" "a bc d" 16*53f60528SJilles Tjoelkerassign_pipeline=$(printf "$fmt" | cat) 17*53f60528SJilles Tjoelkercheck "$LINENO" "$assign_pipeline" "a bc d" 18*53f60528SJilles Tjoelkerset -- $(printf "$fmt") $(printf "$fmt" | cat) "$(printf "$fmt")" "$(printf "$fmt" | cat)" 19*53f60528SJilles TjoelkerIFS=@ 20*53f60528SJilles Tjoelkersplits="$*" 21*53f60528SJilles Tjoelkercheck "$LINENO" "$splits" "a@bc@d@a@bc@d@a bc d@a bc d" 22*53f60528SJilles Tjoelker 23*53f60528SJilles Tjoelker[ "$failures" = 0 ] 24