| 1 | #!/usr/bin/env python3
|
| 2 | """
|
| 3 | Test history expansion
|
| 4 |
|
| 5 | To invoke this file, run the shell wrapper:
|
| 6 |
|
| 7 | test/stateful.sh history-quick
|
| 8 | """
|
| 9 | from __future__ import print_function
|
| 10 |
|
| 11 | import sys
|
| 12 |
|
| 13 | import harness
|
| 14 | from harness import expect_prompt, register
|
| 15 |
|
| 16 | from test.spec_lib import log
|
| 17 |
|
| 18 |
|
| 19 | @register()
|
| 20 | def 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'])
|
| 35 | def 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 |
|
| 46 | if __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)
|