1 #### history -a
2 rm -f tmp
3
4 echo '
5 history -c
6
7 HISTFILE=tmp
8 echo 1
9 history -a
10 cat tmp
11
12 echo 2
13
14 cat tmp
15 ' | $SH -i
16
17 # match osh's behaviour of echoing ^D for EOF
18 case $SH in bash) echo '^D' ;; esac
19
20 ## STDOUT:
21 1
22 HISTFILE=tmp
23 echo 1
24 history -a
25 2
26 HISTFILE=tmp
27 echo 1
28 history -a
29 ^D
30 ## END
31
32 #### history -r
33 rm -f tmp
34 echo 'foo' > tmp
35
36 echo '
37 history -c
38
39 HISTFILE=tmp
40 history -r
41 history
42 ' | $SH -i
43
44 # match osh's behaviour of echoing ^D for EOF
45 case $SH in bash) echo '^D' ;; esac
46
47 ## STDOUT:
48 1 HISTFILE=tmp
49 2 history -r
50 3 foo
51 4 history
52 ^D
53 ## END
54
55 #### HISTFILE is defined initially
56 echo '
57 if test -n $HISTFILE; then echo exists; fi
58 ' | $SH -i
59
60 # match osh's behaviour of echoing ^D for EOF
61 case $SH in bash) echo '^D' ;; esac
62
63 ## STDOUT:
64 exists
65 ^D
66 ## END
67
68 #### HISTFILE must point to a file
69
70 echo '
71 HISTFILE=_tmp/does-not-exist
72 history -r
73 echo $?
74 ' | $SH -i
75
76 # match osh's behaviour of echoing ^D for EOF
77 case $SH in bash) echo '^D' ;; esac
78
79 ## STDOUT:
80 1
81 ^D
82 ## END
83
84 #### HISTFILE must be a string
85
86 # TODO: we should support bash's behaviour here
87
88 echo '
89 HISTFILE=(a b c)
90 history -a
91 echo $?
92 ' | $SH -i
93
94 ## STDOUT:
95 0
96 ## END
97 ## OK osh STDOUT:
98 1
99 ^D
100 ## END
101
102 #### history -d to delete history item
103
104 # TODO: Respect HISTFILE and fix this test
105
106 history -d 1
107 echo status=$?
108
109 # problem: default for integers is -1
110 history -d -1
111 echo status=$?
112 history -d -2
113 echo status=$?
114
115 ## STDOUT:
116 status=0
117 status=1
118 status=1
119 ## END