1 | ## oils_failures_allowed: 2
|
2 | ## compare_shells: dash bash mksh zsh ash
|
3 |
|
4 | #### Parsing shell words \r \v
|
5 |
|
6 | # frontend/lexer_def.py has rules for this
|
7 |
|
8 | tab=$(python2 -c 'print "argv.py -\t-"')
|
9 | cr=$(python2 -c 'print "argv.py -\r-"')
|
10 | vert=$(python2 -c 'print "argv.py -\v-"')
|
11 | ff=$(python2 -c 'print "argv.py -\f-"')
|
12 |
|
13 | $SH -c "$tab"
|
14 | $SH -c "$cr"
|
15 | $SH -c "$vert"
|
16 | $SH -c "$ff"
|
17 |
|
18 | ## STDOUT:
|
19 | ['-', '-']
|
20 | ['-\r-']
|
21 | ['-\x0b-']
|
22 | ['-\x0c-']
|
23 | ## END
|
24 |
|
25 | #### \r in arith expression is allowed by some shells, but not most!
|
26 |
|
27 | arith=$(python2 -c 'print "argv.py $(( 1 +\n2))"')
|
28 | arith_cr=$(python2 -c 'print "argv.py $(( 1 +\r\n2))"')
|
29 |
|
30 | $SH -c "$arith"
|
31 | if test $? -ne 0; then
|
32 | echo 'failed'
|
33 | fi
|
34 |
|
35 | $SH -c "$arith_cr"
|
36 | if test $? -ne 0; then
|
37 | echo 'failed'
|
38 | fi
|
39 |
|
40 | ## STDOUT:
|
41 | ['3']
|
42 | failed
|
43 | ## END
|
44 |
|
45 | ## OK mksh/ash/osh STDOUT:
|
46 | ['3']
|
47 | ['3']
|
48 | ## END
|
49 |
|
50 | #### whitespace in string to integer conversion
|
51 |
|
52 | tab=$(python2 -c 'print "\t42\t"')
|
53 | cr=$(python2 -c 'print "\r42\r"')
|
54 |
|
55 | $SH -c 'echo $(( $1 + 1 ))' dummy0 "$tab"
|
56 | if test $? -ne 0; then
|
57 | echo 'failed'
|
58 | fi
|
59 |
|
60 | $SH -c 'echo $(( $1 + 1 ))' dummy0 "$cr"
|
61 | if test $? -ne 0; then
|
62 | echo 'failed'
|
63 | fi
|
64 |
|
65 | ## STDOUT:
|
66 | 43
|
67 | failed
|
68 | ## END
|
69 |
|
70 | ## OK mksh/ash/osh STDOUT:
|
71 | 43
|
72 | 43
|
73 | ## END
|
74 |
|
75 | #### \r at end of line is not special
|
76 |
|
77 | # hm I wonder if Windows ports have rules for this?
|
78 |
|
79 | cr=$(python2 -c 'print "argv.py -\r"')
|
80 |
|
81 | $SH -c "$cr"
|
82 |
|
83 | ## STDOUT:
|
84 | ['-\r']
|
85 | ## END
|
86 |
|
87 | #### Default IFS does not include \r \v \f
|
88 |
|
89 | # dash and zsh don't have echo -e
|
90 | tab=$(python2 -c 'print "-\t-"')
|
91 | cr=$(python2 -c 'print "-\r-"')
|
92 | vert=$(python2 -c 'print "-\v-"')
|
93 | ff=$(python2 -c 'print "-\f-"')
|
94 |
|
95 | $SH -c 'argv.py $1' dummy0 "$tab"
|
96 | $SH -c 'argv.py $1' dummy0 "$cr"
|
97 | $SH -c 'argv.py $1' dummy0 "$vert"
|
98 | $SH -c 'argv.py $1' dummy0 "$ff"
|
99 |
|
100 | ## STDOUT:
|
101 | ['-', '-']
|
102 | ['-\r-']
|
103 | ['-\x0b-']
|
104 | ['-\x0c-']
|
105 | ## END
|
106 |
|
107 | # No word splitting in zsh
|
108 |
|
109 | ## OK zsh STDOUT:
|
110 | ['-\t-']
|
111 | ['-\r-']
|
112 | ['-\x0b-']
|
113 | ['-\x0c-']
|
114 | ## END
|
115 |
|