2020-03-03 07:20:29 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
2021-05-23 21:25:12 +08:00
|
|
|
import os
|
|
|
|
import platform
|
|
|
|
import sys
|
|
|
|
|
|
|
|
# Skip on macOS on Github Actions because it's too resource-starved
|
|
|
|
# and fails this a lot.
|
|
|
|
#
|
|
|
|
# Presumably we still have users on macOS that would notice binding errors
|
|
|
|
if "GITHUB_WORKFLOW" in os.environ and platform.system() == "Darwin":
|
|
|
|
sys.exit(127)
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
sp = SpawnedProc()
|
2020-10-15 01:26:13 +08:00
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
|
|
|
sp.expect_str,
|
|
|
|
)
|
2020-10-07 05:22:35 +08:00
|
|
|
expect_prompt()
|
2020-08-25 04:19:57 +08:00
|
|
|
|
|
|
|
# Clear twice (regression test for #7280).
|
|
|
|
send("\f")
|
|
|
|
expect_prompt(increment=False)
|
|
|
|
send("\f")
|
|
|
|
expect_prompt(increment=False)
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Fish should start in default-mode (i.e., emacs) bindings. The default escape
|
|
|
|
# timeout is 30ms.
|
2020-11-07 14:42:40 +08:00
|
|
|
#
|
|
|
|
# Because common CI systems are awful, we have to increase this:
|
|
|
|
|
2021-05-03 17:26:02 +08:00
|
|
|
sendline("set -g fish_escape_delay_ms 120")
|
2020-11-07 14:42:40 +08:00
|
|
|
expect_prompt("")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo abc def")
|
|
|
|
send("\033t\r")
|
|
|
|
expect_prompt("\r\ndef abc\r\n") # emacs transpose words, default timeout: no delay
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Now test with a delay > 0 and < the escape timeout. This should transpose
|
|
|
|
# the words.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo ghi jkl")
|
|
|
|
send("\033")
|
|
|
|
sleep(0.010)
|
|
|
|
send("t\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
# emacs transpose words, default timeout: short delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt("\r\njkl ghi\r\n")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo mno pqr")
|
|
|
|
send("\033")
|
2020-12-10 00:52:17 +08:00
|
|
|
sleep(0.250)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("t\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
# emacs transpose words, default timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt("\r\nmno pqrt\r\n")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Now test that exactly the expected bind modes are defined
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("bind --list-modes")
|
|
|
|
expect_prompt("\r\ndefault\r\npaste", unmatched="Unexpected bind modes")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Test vi key bindings.
|
|
|
|
# This should leave vi mode in the insert state.
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("set -g fish_key_bindings fish_vi_key_bindings")
|
|
|
|
expect_prompt()
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Go through a prompt cycle to let fish catch up, it may be slow due to ASAN
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("echo success: default escape timeout")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nsuccess: default escape timeout", unmatched="prime vi mode, default timeout"
|
|
|
|
)
|
|
|
|
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo fail: default escape timeout")
|
2021-04-23 03:43:04 +08:00
|
|
|
expect_str("echo fail: default escape timeout")
|
2020-06-05 09:13:39 +08:00
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode. The delay is
|
|
|
|
# longer than strictly necessary to let fish catch up as it may be slow due to
|
|
|
|
# ASAN.
|
2020-11-10 02:08:00 +08:00
|
|
|
sleep(0.250)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("ddi")
|
|
|
|
sendline("echo success: default escape timeout")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nsuccess: default escape timeout\r\n",
|
|
|
|
unmatched="vi replace line, default timeout: long delay",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Test replacing a single character.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo TEXT")
|
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2022-12-23 19:17:25 +08:00
|
|
|
# Specifically alt+h *is* bound to __fish_man_page,
|
|
|
|
# and I have seen this think that trigger with 300ms.
|
|
|
|
#
|
|
|
|
# The next step is to rip out this test because it's much more pain than it is worth
|
|
|
|
sleep(0.400)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("hhrAi\r")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nTAXT\r\n", unmatched="vi mode replace char, default timeout: long delay"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Test deleting characters with 'x'.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo MORE-TEXT")
|
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2022-12-23 19:17:25 +08:00
|
|
|
sleep(0.400)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("xxxxx\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# vi mode delete char, default timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nMORE\r\n", unmatched="vi mode delete char, default timeout: long delay"
|
|
|
|
)
|
|
|
|
|
|
|
|
# Test jumping forward til before a character with t
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo MORE-TEXT-IS-NICE")
|
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2020-06-05 09:13:39 +08:00
|
|
|
sleep(0.250)
|
|
|
|
send("0tTD\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# vi mode forward-jump-till character, default timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nMORE\r\n",
|
|
|
|
unmatched="vi mode forward-jump-till character, default timeout: long delay",
|
|
|
|
)
|
|
|
|
|
2021-09-25 02:41:09 +08:00
|
|
|
# DISABLED BECAUSE IT FAILS ON GITHUB ACTIONS
|
2020-03-03 07:20:29 +08:00
|
|
|
# Test jumping backward til before a character with T
|
2021-09-25 02:41:09 +08:00
|
|
|
# send("echo MORE-TEXT-IS-NICE")
|
|
|
|
# send("\033")
|
|
|
|
# # Delay needed to allow fish to transition to vi "normal" mode.
|
|
|
|
# sleep(0.250)
|
|
|
|
# send("TSD\r")
|
|
|
|
# # vi mode backward-jump-till character, default timeout: long delay
|
|
|
|
# expect_prompt(
|
|
|
|
# "\r\nMORE-TEXT-IS\r\n",
|
|
|
|
# unmatched="vi mode backward-jump-till character, default timeout: long delay",
|
|
|
|
# )
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Test jumping backward with F and repeating
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo MORE-TEXT-IS-NICE")
|
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2020-06-05 09:13:39 +08:00
|
|
|
sleep(0.250)
|
|
|
|
send("F-;D\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
# vi mode backward-jump-to character and repeat, default timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nMORE-TEXT\r\n",
|
|
|
|
unmatched="vi mode backward-jump-to character and repeat, default timeout: long delay",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Test jumping backward with F w/reverse jump
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo MORE-TEXT-IS-NICE")
|
|
|
|
send("\033")
|
2020-03-03 07:20:29 +08:00
|
|
|
# Delay needed to allow fish to transition to vi "normal" mode.
|
2020-06-05 09:13:39 +08:00
|
|
|
sleep(0.250)
|
|
|
|
send("F-F-,D\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
# vi mode backward-jump-to character, and reverse, default timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nMORE-TEXT-IS\r\n",
|
|
|
|
unmatched="vi mode backward-jump-to character, and reverse, default timeout: long delay",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Verify that changing the escape timeout has an effect.
|
2020-12-10 00:52:17 +08:00
|
|
|
send("set -g fish_escape_delay_ms 100\r")
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
send("echo fail: lengthened escape timeout")
|
|
|
|
send("\033")
|
2024-01-03 05:42:19 +08:00
|
|
|
sleep(0.400)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("ddi")
|
2024-01-03 05:42:19 +08:00
|
|
|
sleep(0.25)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo success: lengthened escape timeout\r")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nsuccess: lengthened escape timeout\r\n",
|
2020-12-10 00:52:17 +08:00
|
|
|
unmatched="vi replace line, 100ms timeout: long delay",
|
2020-03-03 07:20:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Verify that we don't switch to vi normal mode if we don't wait long enough
|
|
|
|
# after sending escape.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo fail: no normal mode")
|
|
|
|
send("\033")
|
2020-11-12 02:00:49 +08:00
|
|
|
sleep(0.010)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("ddi")
|
|
|
|
send("inserted\r")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nfail: no normal modediinserted\r\n",
|
2020-12-10 00:52:17 +08:00
|
|
|
unmatched="vi replace line, 100ms timeout: short delay",
|
2020-03-03 07:20:29 +08:00
|
|
|
)
|
|
|
|
|
2020-11-12 02:54:25 +08:00
|
|
|
# Now set it back to speed up the tests - these don't use any escape+thing bindings!
|
|
|
|
send("set -g fish_escape_delay_ms 50\r")
|
|
|
|
expect_prompt()
|
|
|
|
|
2020-03-03 07:20:29 +08:00
|
|
|
# Test 't' binding that contains non-zero arity function (forward-jump) followed
|
|
|
|
# by another function (and) https://github.com/fish-shell/fish-shell/issues/2357
|
2020-06-05 09:13:39 +08:00
|
|
|
send("\033")
|
2020-11-12 02:54:25 +08:00
|
|
|
sleep(0.200)
|
2021-04-23 03:43:04 +08:00
|
|
|
send("ddiecho TEXT")
|
|
|
|
expect_str("echo TEXT")
|
|
|
|
send("\033")
|
2020-11-12 02:54:25 +08:00
|
|
|
sleep(0.200)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("hhtTrN\r")
|
|
|
|
expect_prompt("\r\nTENT\r\n", unmatched="Couldn't find expected output 'TENT'")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
2023-08-31 05:10:39 +08:00
|
|
|
# Test sequence key delay
|
|
|
|
send("set -g fish_sequence_key_delay_ms 200\r")
|
|
|
|
expect_prompt()
|
|
|
|
send("bind -M insert jk 'commandline -i foo'\r")
|
|
|
|
expect_prompt()
|
|
|
|
send("echo jk")
|
|
|
|
send("\r")
|
|
|
|
expect_prompt("foo")
|
|
|
|
send("echo j")
|
|
|
|
sleep(0.300)
|
|
|
|
send("k\r")
|
|
|
|
expect_prompt("jk")
|
|
|
|
send("set -e fish_sequence_key_delay_ms\r")
|
|
|
|
expect_prompt()
|
|
|
|
send("echo j")
|
|
|
|
sleep(0.300)
|
|
|
|
send("k\r")
|
|
|
|
expect_prompt("foo")
|
|
|
|
|
|
|
|
|
2020-03-03 07:20:29 +08:00
|
|
|
# Test '~' (togglecase-char)
|
2021-01-26 14:07:51 +08:00
|
|
|
# HACK: Deactivated because it keeps failing on CI
|
|
|
|
# send("\033")
|
|
|
|
# sleep(0.100)
|
|
|
|
# send("cc")
|
|
|
|
# sleep(0.50)
|
|
|
|
# send("echo some TExT\033")
|
|
|
|
# sleep(0.300)
|
|
|
|
# send("hh~~bbve~\r")
|
|
|
|
# expect_prompt("\r\nSOME TeXT\r\n", unmatched="Couldn't find expected output 'SOME TeXT")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Now test that exactly the expected bind modes are defined
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("bind --list-modes")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\ndefault\r\ninsert\r\npaste\r\nreplace\r\nreplace_one\r\nvisual\r\n",
|
|
|
|
unmatched="Unexpected vi bind modes",
|
|
|
|
)
|
|
|
|
|
|
|
|
# Switch back to regular (emacs mode) key bindings.
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("set -g fish_key_bindings fish_default_key_bindings")
|
|
|
|
expect_prompt()
|
2020-03-03 07:20:29 +08:00
|
|
|
|
2020-11-12 02:54:25 +08:00
|
|
|
# Verify the custom escape timeout set earlier is still in effect.
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("echo fish_escape_delay_ms=$fish_escape_delay_ms")
|
|
|
|
expect_prompt(
|
2020-11-12 02:54:25 +08:00
|
|
|
"\r\nfish_escape_delay_ms=50\r\n",
|
2020-03-03 07:20:29 +08:00
|
|
|
unmatched="default-mode custom timeout not set correctly",
|
|
|
|
)
|
|
|
|
|
2020-12-10 00:52:17 +08:00
|
|
|
sendline("set -g fish_escape_delay_ms 200")
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt()
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Verify the emacs transpose word (\et) behavior using various delays,
|
|
|
|
# including none, after the escape character.
|
|
|
|
|
|
|
|
# Start by testing with no delay. This should transpose the words.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo abc def")
|
|
|
|
send("\033")
|
|
|
|
send("t\r")
|
|
|
|
expect_prompt(
|
2020-12-10 00:52:17 +08:00
|
|
|
"\r\ndef abc\r\n", unmatched="emacs transpose words fail, 200ms timeout: no delay"
|
2020-03-03 07:20:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Same test as above but with a slight delay less than the escape timeout.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo ghi jkl")
|
|
|
|
send("\033")
|
2020-11-10 02:53:27 +08:00
|
|
|
sleep(0.020)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("t\r")
|
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\njkl ghi\r\n",
|
2020-12-10 00:52:17 +08:00
|
|
|
unmatched="emacs transpose words fail, 200ms timeout: short delay",
|
2020-03-03 07:20:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Now test with a delay > the escape timeout. The transposition should not
|
|
|
|
# occur and the "t" should become part of the text that is echoed.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo mno pqr")
|
|
|
|
send("\033")
|
2020-12-13 21:57:37 +08:00
|
|
|
sleep(0.350)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("t\r")
|
2020-03-03 07:20:29 +08:00
|
|
|
# emacs transpose words, 100ms timeout: long delay
|
2020-06-05 09:13:39 +08:00
|
|
|
expect_prompt(
|
2020-03-03 07:20:29 +08:00
|
|
|
"\r\nmno pqrt\r\n",
|
2020-12-10 00:52:17 +08:00
|
|
|
unmatched="emacs transpose words fail, 200ms timeout: long delay",
|
2020-03-03 07:20:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Verify special characters, such as \cV, are not intercepted by the kernel
|
|
|
|
# tty driver. Rather, they can be bound and handled by fish.
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("bind \\cV 'echo ctrl-v seen'")
|
|
|
|
expect_prompt()
|
|
|
|
send("\026\r")
|
|
|
|
expect_prompt("ctrl-v seen", unmatched="ctrl-v not seen")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
2020-06-05 09:13:39 +08:00
|
|
|
send("bind \\cO 'echo ctrl-o seen'\r")
|
|
|
|
expect_prompt()
|
|
|
|
send("\017\r")
|
|
|
|
expect_prompt("ctrl-o seen", unmatched="ctrl-o not seen")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# \x17 is ctrl-w.
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo git@github.com:fish-shell/fish-shell")
|
|
|
|
send("\x17\x17\r")
|
|
|
|
expect_prompt("git@github.com:", unmatched="ctrl-w does not stop at :")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
2020-06-05 09:13:39 +08:00
|
|
|
send("echo git@github.com:fish-shell/fish-shell")
|
|
|
|
send("\x17\x17\x17\r")
|
|
|
|
expect_prompt("git@", unmatched="ctrl-w does not stop at @")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
2022-07-02 15:23:11 +08:00
|
|
|
sendline("abbr --add foo 'echo foonanana'")
|
|
|
|
expect_prompt()
|
|
|
|
sendline("bind ' ' expand-abbr or self-insert")
|
|
|
|
expect_prompt()
|
|
|
|
send("foo ")
|
|
|
|
expect_str("echo foonanana")
|
|
|
|
send(" banana\r")
|
|
|
|
expect_str(" banana\r")
|
|
|
|
expect_prompt("foonanana banana")
|
|
|
|
|
2020-03-03 07:20:29 +08:00
|
|
|
# Ensure that nul can be bound properly (#3189).
|
2020-06-05 09:13:39 +08:00
|
|
|
send("bind -k nul 'echo nul seen'\r")
|
2020-08-23 08:48:50 +08:00
|
|
|
expect_prompt()
|
2020-06-05 09:13:39 +08:00
|
|
|
send("\0" * 3)
|
2020-11-20 11:15:37 +08:00
|
|
|
# We need to sleep briefly before emitting a newline, because when we execute the
|
|
|
|
# key bindings above we place the tty in external-proc mode (see #7483) and restoring
|
|
|
|
# the mode to shell-mode races with the newline emitted below (i.e. sometimes it may
|
|
|
|
# be echoed).
|
|
|
|
sleep(0.1)
|
2020-06-05 09:13:39 +08:00
|
|
|
send("\r")
|
|
|
|
expect_prompt("nul seen\r\nnul seen\r\nnul seen", unmatched="nul not seen")
|
2020-03-03 07:20:29 +08:00
|
|
|
|
|
|
|
# Test self-insert-notfirst. (#6603)
|
|
|
|
# Here the leading 'q's should be stripped, but the trailing ones not.
|
2020-06-05 09:13:39 +08:00
|
|
|
sendline("bind q self-insert-notfirst")
|
|
|
|
expect_prompt()
|
|
|
|
sendline("qqqecho qqq")
|
|
|
|
expect_prompt("qqq", unmatched="Leading qs not stripped")
|
2020-09-12 02:13:06 +08:00
|
|
|
|
|
|
|
# Test bigword with single-character words.
|
|
|
|
sendline("bind \cg kill-bigword")
|
|
|
|
expect_prompt()
|
2020-10-07 05:22:35 +08:00
|
|
|
send("a b c d\x01") # ctrl-a, move back to the beginning of the line
|
|
|
|
send("\x07") # ctrl-g, kill bigword
|
2020-09-12 02:13:06 +08:00
|
|
|
sendline("echo")
|
2020-10-07 07:03:06 +08:00
|
|
|
expect_prompt("\nb c d")
|
2020-09-12 02:13:06 +08:00
|
|
|
|
2021-11-11 03:39:28 +08:00
|
|
|
# Test that overriding the escape binding works
|
|
|
|
# and does not inhibit other escape sequences (up-arrow in this case).
|
|
|
|
sendline("bind \\x1b 'echo foo'")
|
|
|
|
expect_prompt()
|
|
|
|
send("\x1b")
|
|
|
|
expect_str("foo")
|
|
|
|
send("\x1b[A")
|
|
|
|
expect_str("bind \\x1b 'echo foo'")
|
|
|
|
sendline("")
|
|
|
|
expect_prompt()
|
|
|
|
|
2020-10-07 05:22:35 +08:00
|
|
|
send(" a b c d\x01") # ctrl-a, move back to the beginning of the line
|
|
|
|
send("\x07") # ctrl-g, kill bigword
|
2020-09-12 02:13:06 +08:00
|
|
|
sendline("echo")
|
2020-10-07 07:03:06 +08:00
|
|
|
expect_prompt("\nb c d")
|
2020-10-15 01:26:13 +08:00
|
|
|
|
|
|
|
# Check that ctrl-z can be bound
|
|
|
|
sendline('bind \cz "echo bound ctrl-z"')
|
|
|
|
expect_prompt()
|
2020-11-22 21:39:48 +08:00
|
|
|
send("\x1A")
|
2020-10-15 01:26:13 +08:00
|
|
|
expect_str("bound ctrl-z")
|
2021-05-03 02:20:48 +08:00
|
|
|
|
|
|
|
# Check that the builtin version of `exit` works
|
|
|
|
# (for obvious reasons this MUST BE LAST)
|
2022-06-17 00:43:28 +08:00
|
|
|
sendline("function myexit; echo exit; exit; end; bind \cz myexit")
|
2021-05-03 02:20:48 +08:00
|
|
|
expect_prompt()
|
|
|
|
send("\x1A")
|
|
|
|
expect_str("exit")
|
|
|
|
|
2021-05-03 17:26:41 +08:00
|
|
|
for t in range(0, 50):
|
2021-05-03 02:20:48 +08:00
|
|
|
if not sp.spawn.isalive():
|
|
|
|
break
|
|
|
|
# This is cheesy, but on CI with thread-sanitizer this can be slow enough that the process is still running, so we sleep for a bit.
|
2021-05-03 17:26:41 +08:00
|
|
|
sleep(0.1)
|
2021-05-03 02:20:48 +08:00
|
|
|
else:
|
|
|
|
print("Fish did not exit via binding!")
|
|
|
|
sys.exit(1)
|