1 |
## tags: interactive
|
2 |
## compare_shells: bash
|
3 |
|
4 |
|
5 |
rm -f tmp
|
6 |
|
7 |
echo '
|
8 |
history -c
|
9 |
|
10 |
HISTFILE=tmp
|
11 |
echo 1
|
12 |
history -a
|
13 |
cat tmp
|
14 |
|
15 |
echo 2
|
16 |
|
17 |
cat tmp
|
18 |
' | $SH -i
|
19 |
|
20 |
# match osh's behaviour of echoing ^D for EOF
|
21 |
case $SH in bash) echo '^D' ;; esac
|
22 |
|
23 |
## STDOUT:
|
24 |
1
|
25 |
HISTFILE=tmp
|
26 |
echo 1
|
27 |
history -a
|
28 |
2
|
29 |
HISTFILE=tmp
|
30 |
echo 1
|
31 |
history -a
|
32 |
^D
|
33 |
## END
|
34 |
|
35 |
|
36 |
rm -f tmp
|
37 |
echo 'foo' > tmp
|
38 |
|
39 |
echo '
|
40 |
history -c
|
41 |
|
42 |
HISTFILE=tmp
|
43 |
history -r
|
44 |
history
|
45 |
' | $SH -i
|
46 |
|
47 |
# match osh's behaviour of echoing ^D for EOF
|
48 |
case $SH in bash) echo '^D' ;; esac
|
49 |
|
50 |
## STDOUT:
|
51 |
1 HISTFILE=tmp
|
52 |
2 history -r
|
53 |
3 foo
|
54 |
4 history
|
55 |
^D
|
56 |
## END
|
57 |
|
58 |
|
59 |
echo '
|
60 |
if test -n $HISTFILE; then echo exists; fi
|
61 |
' | $SH -i
|
62 |
|
63 |
# match osh's behaviour of echoing ^D for EOF
|
64 |
case $SH in bash) echo '^D' ;; esac
|
65 |
|
66 |
## STDOUT:
|
67 |
exists
|
68 |
^D
|
69 |
## END
|
70 |
|
71 |
|
72 |
|
73 |
rm -f _tmp/does-not-exist
|
74 |
|
75 |
echo '
|
76 |
HISTFILE=_tmp/does-not-exist
|
77 |
history -r
|
78 |
echo status=$?
|
79 |
' | $SH -i
|
80 |
|
81 |
# match osh's behaviour of echoing ^D for EOF
|
82 |
case $SH in bash) echo '^D' ;; esac
|
83 |
|
84 |
## STDOUT:
|
85 |
status=1
|
86 |
^D
|
87 |
## END
|
88 |
|
89 |
|
90 |
|
91 |
echo '
|
92 |
HISTFILE=(a b c)
|
93 |
history -a
|
94 |
echo status=$?
|
95 |
' | $SH -i
|
96 |
|
97 |
case $SH in bash) echo '^D' ;; esac
|
98 |
|
99 |
# note that bash actually writes the file 'a', since that's ${HISTFILE[0]}
|
100 |
|
101 |
## STDOUT:
|
102 |
status=1
|
103 |
^D
|
104 |
## END
|
105 |
|
106 |
## OK bash STDOUT:
|
107 |
status=0
|
108 |
^D
|
109 |
## END
|
110 |
|
111 |
|
112 |
|
113 |
echo '
|
114 |
unset HISTFILE
|
115 |
history -a
|
116 |
echo status=$?
|
117 |
' | $SH -i
|
118 |
|
119 |
case $SH in bash) echo '^D' ;; esac
|
120 |
|
121 |
## STDOUT:
|
122 |
status=1
|
123 |
^D
|
124 |
## END
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
rm -f myhist
|
130 |
export HISTFILE=myhist
|
131 |
|
132 |
$SH --norc -i <<'EOF'
|
133 |
|
134 |
echo 42
|
135 |
echo 43
|
136 |
echo 44
|
137 |
|
138 |
history -a
|
139 |
|
140 |
history -d 1
|
141 |
echo status=$?
|
142 |
|
143 |
# Invalid integers
|
144 |
history -d -1
|
145 |
echo status=$?
|
146 |
history -d -2
|
147 |
echo status=$?
|
148 |
history -d 99
|
149 |
echo status=$?
|
150 |
|
151 |
case $SH in bash*) echo '^D' ;; esac
|
152 |
|
153 |
EOF
|
154 |
|
155 |
## STDOUT:
|
156 |
42
|
157 |
43
|
158 |
44
|
159 |
status=0
|
160 |
status=2
|
161 |
status=2
|
162 |
status=2
|
163 |
^D
|
164 |
## END
|
165 |
|
166 |
# bash-4.4 used to give more errors like OSH? Weird
|
167 |
|
168 |
## BUG bash STDOUT:
|
169 |
42
|
170 |
43
|
171 |
44
|
172 |
status=0
|
173 |
status=0
|
174 |
status=0
|
175 |
status=1
|
176 |
^D
|
177 |
## END
|
178 |
|
179 |
|
180 |
|
181 |
history not-a-number
|
182 |
echo status=$?
|
183 |
|
184 |
history 3 too-many
|
185 |
echo status=$?
|
186 |
|
187 |
## STDOUT:
|
188 |
status=2
|
189 |
status=2
|
190 |
## END
|
191 |
|
192 |
## OK bash STDOUT:
|
193 |
status=1
|
194 |
status=1
|
195 |
## END
|
196 |
|
197 |
|
198 |
|