source: vendor/bash/3.1-p17/tests/histexp.tests

Last change on this file was 3228, checked in by bird, 18 years ago

bash 3.1

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