Imported from ../bash-2.01.tar.gz.
[platform/upstream/bash.git] / tests / histexpand.tests
1 trap 'rm /tmp/newhistory' 0
2
3 file=bax
4
5 history -c
6
7 HISTFILE=history.list
8 HISTCONTROL=ignoreboth
9 HISTIGNORE='&:#*:history*:fc*'
10 # we will end up exercising the history stifling code as a result
11 HISTSIZE=32
12
13 shopt -s cmdhist
14 set -o history
15
16 history -p '!!'
17
18 history
19
20 HISTFILE=/tmp/newhistory
21 history -a
22
23 history -w
24
25 history -s "echo line 2 for history"
26 history
27 history -p '!e'
28 history -p '!!'
29
30 set -H
31 !!
32 !e
33
34 history
35
36 echo a b c d e
37 !?ch?
38 !-2
39 ^2^8
40
41 !2
42
43 # we're selecting /bin/sh -c ...; we want `sh'
44 echo !-1:0:t
45 # we're selecting /bin/sh -c ...; we want `/bin'
46 echo !-2:0:h
47 # we're selecting `echo a b c d e'; we want `e'
48 echo !?d?:5
49
50 echo a b c d e
51 echo !-1:2-$
52 echo !-2:2-4
53 echo !-2:3*
54 echo !!:*
55
56 echo !?a?:2-
57
58 echo file.c
59 echo !!:$:r
60 echo !-2:$:e
61 echo !-3:$:r:q
62
63 echo $file.c
64 echo !!:$:r
65 echo !-2:^:e
66 echo !-3:$:r:q
67
68 echo a b c d e
69 echo !!:1-$:x
70 echo !-2:1-$:q
71
72 echo foo.c foo.o foo.html foo.h
73 !!:s/foo/bar/
74 !-2:gs/foo/bar/
75 !!:gs/bar/x&/
76 !-2:g&
77
78 # make sure we can use any delimiter in the substitution, not just `/'
79 !!:gs+bar+whix+
80
81 !!:p
82
83 # wow
84 echo !?.o?:%:r:q
85
86 !!:0 !?.h?:%:q
87 !!:-$
88 !:-$
89
90 history
91
92 # make sure single quotes inhibit history expansion
93 echo '!!'
94
95 # make sure backslashes can quote the history expansion character
96 echo \!\!
97
98 # but other expansions on the line should still be processed
99
100 echo '!!' !!:*
101 history -c
102 unset HISTFILE
103
104 # make sure that the special bash cases are not history expanded
105 case p in
106 [!A-Z]) echo ok 1;;
107 esac
108
109 var1='ok 2'
110 var2=var1
111
112 echo ${!var2}