]> git.ipfire.org Git - thirdparty/bash.git/blame - tests/history.tests
bash-5.1 distribution sources and documentation
[thirdparty/bash.git] / tests / history.tests
CommitLineData
8868edaf
CR
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#
d233b485 14trap 'rm $TMPDIR/newhistory' 0
d166f048 15
cce855bc
JA
16# bad options
17history -x
18# cannot use -r and -w at the same time
19history -r -w /dev/null
20
21# bad option
22fc -v
23
95732b49
JA
24unset HISTFILESIZE
25
cce855bc
JA
26# all of these should result in an empty history list
27history -c
28history -r /dev/null
29history -n /dev/null
d166f048
JA
30history -c
31
32HISTFILE=history.list
33HISTCONTROL=ignoreboth
34HISTIGNORE='&:history*:fc*'
35HISTSIZE=32
d233b485 36export HISTIGNORE
d166f048
JA
37
38shopt -s cmdhist
39set -o history
40
41history
42
43fc -l
44fc -nl
45
46fc -lr
47fc -nlr
48
49history -s "echo line for history"
50history
51
52history -p '!!'
53
54fc -nl
55
d233b485 56HISTFILE=$TMPDIR/newhistory
d166f048
JA
57history -a
58echo displaying \$HISTFILE after history -a
59cat $HISTFILE
60
61history
62history -w
63cat $HISTFILE
64
65history -s "echo line 2 for history"
66history
67history -p '!e'
68history -p '!!'
69
70# this should show up as one history entry
71for x in one two three
72do
73 :
74done
75history
76
77# just a basic test. a full test suite for history expansion should be
78# created
79set -H
80!!
81!e
82
83unset HISTSIZE
84unset HISTFILE
85
86fc -l 4
87fc -l 4 8
88
8868edaf 89# now an out-of-range error because of the one=two not found in history
cce855bc 90fc -l one=two three=four 502
d166f048
JA
91
92history 4
93
94shopt -so history
95shopt -s expand_aliases
96
97alias r="fc -s"
98
99echo aa ab ac
100
101r a=x
cce855bc 102r x=4 b=8
d166f048
JA
103
104# this had better fail with `no command found'
105r cc
106
107unalias -a
108alias
109
3185942a
JA
110# these two blocks had better both result in the same output
111echo aa
112echo bb
113echo cc
114fc -e cat
115
116echo aa
117echo bb
118echo cc
119fc -e cat -1
120
d166f048
JA
121set +o history
122
123shopt -q -o history
124echo $?
3185942a
JA
125
126${THIS_SH} ./history1.sub
a0c0a00f 127rm -f $TMPDIR/foohist-*
0001803f
CR
128
129${THIS_SH} ./history2.sub
d233b485 130${THIS_SH} ./history3.sub
8868edaf
CR
131${THIS_SH} ./history4.sub
132${THIS_SH} ./history5.sub