]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/history.tests
53321f051d161e4cf65a25203724546c504f7ed7
[thirdparty/bash.git] / tests / history.tests
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
5 #
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU General Public License for more details.
10 #
11 # You should have received a copy of the GNU General Public License
12 # along with this program. If not, see <http://www.gnu.org/licenses/>.
13 #
14 trap 'rm $TMPDIR/newhistory' 0
15
16 # bad options
17 history -x
18 # cannot use -r and -w at the same time
19 history -r -w /dev/null
20
21 # bad option
22 fc -v
23
24 unset HISTFILESIZE
25
26 # all of these should result in an empty history list
27 history -c
28 history -r /dev/null
29 history -n /dev/null
30 history -c
31
32 HISTFILE=history.list
33 HISTCONTROL=ignoreboth
34 HISTIGNORE='&:history*:fc*'
35 HISTSIZE=32
36 export HISTIGNORE
37
38 shopt -s cmdhist
39 set -o history
40
41 history
42
43 fc -l
44 fc -nl
45
46 fc -lr
47 fc -nlr
48
49 history -s "echo line for history"
50 history
51
52 history -p '!!'
53
54 fc -nl
55
56 HISTFILE=$TMPDIR/newhistory
57 history -a
58 echo displaying \$HISTFILE after history -a
59 cat $HISTFILE
60
61 history
62 history -w
63 cat $HISTFILE
64
65 history -s "echo line 2 for history"
66 history
67 history -p '!e'
68 history -p '!!'
69
70 # this should show up as one history entry
71 for x in one two three
72 do
73 :
74 done
75 history
76
77 # just a basic test. a full test suite for history expansion should be
78 # created
79 set -H
80 !!
81 !e
82
83 unset HISTSIZE
84 unset HISTFILE
85
86 fc -l 4
87 fc -l 4 8
88
89 # now an out-of-range error because of the one=two not found in history
90 fc -l one=two three=four 502
91
92 history 4
93
94 shopt -so history
95 shopt -s expand_aliases
96
97 alias r="fc -s"
98
99 echo aa ab ac
100
101 r a=x
102 r x=4 b=8
103
104 # this had better fail with `no command found'
105 r cc
106
107 unalias -a
108 alias
109
110 # these two blocks had better both result in the same output
111 echo aa
112 echo bb
113 echo cc
114 fc -e cat
115
116 echo aa
117 echo bb
118 echo cc
119 fc -e cat -1
120
121 set +o history
122
123 shopt -q -o history
124 echo $?
125
126 ${THIS_SH} ./history1.sub
127 rm -f $TMPDIR/foohist-*
128
129 ${THIS_SH} ./history2.sub
130 ${THIS_SH} ./history3.sub
131 ${THIS_SH} ./history4.sub
132 ${THIS_SH} ./history5.sub