OILS / spec / stateful / history_expand.py View on Github | oils.pub

51 lines, 27 significant
1#!/usr/bin/env python3
2"""
3Test history expansion
4
5To invoke this file, run the shell wrapper:
6
7 test/stateful.sh history-quick
8"""
9from __future__ import print_function
10
11import sys
12
13import harness
14from harness import expect_prompt, register
15
16from test.spec_lib import log
17
18
19@register()
20def history_bangbang(sh):
21 """test basic !! expansion - previous command"""
22 expect_prompt(sh)
23
24 sh.sendline('echo 11')
25 sh.expect('11')
26
27 sh.sendline('echo 22')
28 sh.expect('22')
29
30 sh.sendline('echo !!')
31 sh.expect('echo 22')
32
33
34@register(not_impl_shells=['bash'])
35def history_bangbang(sh):
36 """Inside double quotes, !! should not be expanded, unlike bash """
37 expect_prompt(sh)
38
39 sh.sendline('echo 33')
40 sh.expect('33')
41
42 sh.sendline('echo "!!"')
43 sh.expect('!!')
44
45
46if __name__ == '__main__':
47 try:
48 sys.exit(harness.main(sys.argv))
49 except RuntimeError as e:
50 print('FATAL: %s' % e, file=sys.stderr)
51 sys.exit(1)