1 | ## compare_shells: dash bash mksh zsh ash
|
2 | ## oils_failures_allowed: 2
|
3 | ## oils_cpp_failures_allowed: 1
|
4 |
|
5 | #### NUL bytes with echo -e
|
6 | case $SH in (dash) exit ;; esac
|
7 |
|
8 | echo -e '\0-'
|
9 | #echo -e '\x00-'
|
10 | #echo -e '\000-'
|
11 |
|
12 | ## stdout-repr: "\x00-\n"
|
13 | ## BUG zsh stdout-repr: "\x00\n"
|
14 | ## N-I dash stdout-json: ""
|
15 |
|
16 | #### NUL bytes in printf format
|
17 | printf '\0\n'
|
18 | ## stdout-repr: "\x00\n"
|
19 |
|
20 | #### NUL bytes in printf value (OSH and zsh agree)
|
21 | case $SH in (dash) exit ;; esac
|
22 |
|
23 | nul=$'\0'
|
24 | echo "$nul"
|
25 | printf '%s\n' "$nul"
|
26 |
|
27 | ## stdout-repr: "\n\n"
|
28 | ## OK osh/zsh stdout-repr: "\x00\n\x00\n"
|
29 | ## N-I dash stdout-json: ""
|
30 |
|
31 |
|
32 |
|
33 | #### NUL bytes with echo $'\0' (OSH and zsh agree)
|
34 |
|
35 | case $SH in (dash) exit ;; esac
|
36 |
|
37 | # OSH agrees with ZSH -- so you have the ability to print NUL bytes without
|
38 | # legacy echo -e
|
39 |
|
40 | echo $'\0'
|
41 |
|
42 | ## stdout-repr: "\n"
|
43 | ## OK osh/zsh stdout-repr: "\0\n"
|
44 | ## N-I dash stdout-json: ""
|
45 |
|
46 |
|
47 | #### NUL bytes and IFS splitting
|
48 | case $SH in (dash) exit ;; esac
|
49 |
|
50 | argv.py $(echo -e '\0')
|
51 | argv.py "$(echo -e '\0')"
|
52 | argv.py $(echo -e 'a\0b')
|
53 | argv.py "$(echo -e 'a\0b')"
|
54 |
|
55 | ## STDOUT:
|
56 | []
|
57 | ['']
|
58 | ['ab']
|
59 | ['ab']
|
60 | ## END
|
61 | ## BUG zsh STDOUT:
|
62 | ['', '']
|
63 | ['']
|
64 | ['a', 'b']
|
65 | ['a']
|
66 | ## END
|
67 |
|
68 | ## N-I dash STDOUT:
|
69 | ## END
|
70 |
|
71 | #### NUL bytes with test -n
|
72 |
|
73 | case $SH in (dash) exit ;; esac
|
74 |
|
75 | # zsh is buggy here, weird
|
76 | test -n $''
|
77 | echo status=$?
|
78 |
|
79 | test -n $'\0'
|
80 | echo status=$?
|
81 |
|
82 |
|
83 | ## STDOUT:
|
84 | status=1
|
85 | status=1
|
86 | ## END
|
87 | ## OK osh STDOUT:
|
88 | status=1
|
89 | status=0
|
90 | ## END
|
91 | ## BUG zsh STDOUT:
|
92 | status=0
|
93 | status=0
|
94 | ## END
|
95 |
|
96 | ## N-I dash STDOUT:
|
97 | ## END
|
98 |
|
99 |
|
100 | #### NUL bytes with test -f
|
101 |
|
102 | case $SH in (dash) exit ;; esac
|
103 |
|
104 |
|
105 | test -f $'\0'
|
106 | echo status=$?
|
107 |
|
108 | touch foo
|
109 | test -f $'foo\0'
|
110 | echo status=$?
|
111 |
|
112 | test -f $'foo\0bar'
|
113 | echo status=$?
|
114 |
|
115 | test -f $'foobar'
|
116 | echo status=$?
|
117 |
|
118 |
|
119 | ## STDOUT:
|
120 | status=1
|
121 | status=0
|
122 | status=0
|
123 | status=1
|
124 | ## END
|
125 |
|
126 | ## OK ash STDOUT:
|
127 | status=1
|
128 | status=0
|
129 | status=1
|
130 | status=1
|
131 | ## END
|
132 |
|
133 | ## N-I dash STDOUT:
|
134 | ## END
|
135 |
|
136 |
|
137 | #### NUL bytes with ${#s} (OSH and zsh agree)
|
138 |
|
139 | case $SH in (dash) exit ;; esac
|
140 |
|
141 | empty=$''
|
142 | nul=$'\0'
|
143 |
|
144 | echo empty=${#empty}
|
145 | echo nul=${#nul}
|
146 |
|
147 |
|
148 | ## STDOUT:
|
149 | empty=0
|
150 | nul=0
|
151 | ## END
|
152 |
|
153 | ## OK osh/zsh STDOUT:
|
154 | empty=0
|
155 | nul=1
|
156 | ## END
|
157 |
|
158 | ## N-I dash STDOUT:
|
159 | ## END
|