2024-04-12 10:19:32 +00:00
|
|
|
#RUN: %fish %s
|
2022-04-01 19:05:27 +00:00
|
|
|
|
|
|
|
# Universal abbreviations are imported.
|
|
|
|
set -U _fish_abbr_cuckoo somevalue
|
|
|
|
set fish (status fish-path)
|
|
|
|
$fish -c abbr
|
2023-01-18 18:58:51 +00:00
|
|
|
# CHECK: abbr -a -- cuckoo somevalue # imported from a universal variable, see `help abbr`
|
2022-04-01 19:05:27 +00:00
|
|
|
|
2019-06-26 19:00:54 +00:00
|
|
|
# Test basic add and list of __abbr1
|
|
|
|
abbr __abbr1 alpha beta gamma
|
|
|
|
abbr | grep __abbr1
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr1 'alpha beta gamma'
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Erasing one that doesn\'t exist should do nothing
|
|
|
|
abbr --erase NOT_AN_ABBR
|
|
|
|
abbr | grep __abbr1
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr1 'alpha beta gamma'
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Adding existing __abbr1 should be idempotent
|
|
|
|
abbr __abbr1 alpha beta gamma
|
|
|
|
abbr | grep __abbr1
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr1 'alpha beta gamma'
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Replacing __abbr1 definition
|
|
|
|
abbr __abbr1 delta
|
|
|
|
abbr | grep __abbr1
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr1 delta
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# __abbr1 -s and --show tests
|
|
|
|
abbr -s | grep __abbr1
|
|
|
|
abbr --show | grep __abbr1
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr1 delta
|
|
|
|
# CHECK: abbr -a -- __abbr1 delta
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Test erasing __abbr1
|
|
|
|
abbr -e __abbr1
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# Ensure we escape special characters on output
|
|
|
|
abbr '~__abbr2' '$xyz'
|
|
|
|
abbr | grep __abbr2
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- '~__abbr2' '$xyz'
|
2019-06-26 19:00:54 +00:00
|
|
|
abbr -e '~__abbr2'
|
|
|
|
|
|
|
|
# Ensure we handle leading dashes in abbreviation names properly
|
2020-03-09 18:36:12 +00:00
|
|
|
abbr -- --__abbr3 xyz
|
2019-06-26 19:00:54 +00:00
|
|
|
abbr | grep __abbr3
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- --__abbr3 xyz
|
2020-03-09 18:36:12 +00:00
|
|
|
abbr -e -- --__abbr3
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Test that an abbr word containing spaces is rejected
|
|
|
|
abbr "a b c" "d e f"
|
|
|
|
abbr | grep 'a b c'
|
|
|
|
# CHECKERR: abbr --add: Abbreviation 'a b c' cannot have spaces in the word
|
|
|
|
|
|
|
|
# Test renaming
|
|
|
|
abbr __abbr4 omega
|
|
|
|
abbr | grep __abbr5
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr4 __abbr5
|
2019-06-26 19:00:54 +00:00
|
|
|
abbr | grep __abbr5
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr5 omega
|
2019-06-26 19:00:54 +00:00
|
|
|
abbr -e __abbr5
|
|
|
|
abbr | grep __abbr4
|
|
|
|
|
|
|
|
# Test renaming a nonexistent abbreviation
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr6 __abbr
|
2019-06-26 19:00:54 +00:00
|
|
|
# CHECKERR: abbr --rename: No abbreviation named __abbr6
|
|
|
|
|
|
|
|
# Test renaming to a abbreviation with spaces
|
|
|
|
abbr __abbr4 omega
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr4 "g h i"
|
2019-06-26 19:00:54 +00:00
|
|
|
# CHECKERR: abbr --rename: Abbreviation 'g h i' cannot have spaces in the word
|
|
|
|
abbr -e __abbr4
|
|
|
|
|
|
|
|
# Test renaming without arguments
|
|
|
|
abbr __abbr7 omega
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr7
|
2019-06-26 19:00:54 +00:00
|
|
|
# CHECKERR: abbr --rename: Requires exactly two arguments
|
|
|
|
|
|
|
|
# Test renaming with too many arguments
|
|
|
|
abbr __abbr8 omega
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr8 __abbr9 __abbr10
|
2019-06-26 19:00:54 +00:00
|
|
|
# CHECKERR: abbr --rename: Requires exactly two arguments
|
|
|
|
abbr | grep __abbr8
|
|
|
|
abbr | grep __abbr9
|
|
|
|
abbr | grep __abbr10
|
2022-04-01 19:05:27 +00:00
|
|
|
# CHECK: abbr -a -- __abbr8 omega
|
2019-06-26 19:00:54 +00:00
|
|
|
|
|
|
|
# Test renaming to existing abbreviation
|
|
|
|
abbr __abbr11 omega11
|
|
|
|
abbr __abbr12 omega12
|
2022-12-10 22:16:26 +00:00
|
|
|
abbr --rename __abbr11 __abbr12
|
2019-06-26 19:00:54 +00:00
|
|
|
# CHECKERR: abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11
|
2019-10-06 11:28:42 +00:00
|
|
|
|
|
|
|
abbr __abbr-with-dashes omega
|
|
|
|
complete -C__abbr-with
|
|
|
|
# CHECK: __abbr-with-dashes Abbreviation: omega
|
2020-10-04 10:26:26 +00:00
|
|
|
|
|
|
|
abbr --add --global __abbr13 aaaaaaaaaaaaa
|
|
|
|
abbr --add --global __abbr14 bbbbbbbbbbbbb
|
|
|
|
abbr --erase __abbr13 __abbr14
|
|
|
|
abbr | grep __abbr13
|
|
|
|
abbr | grep __abbr14
|
2021-11-11 15:46:23 +00:00
|
|
|
|
|
|
|
abbr -q banana
|
|
|
|
echo $status
|
|
|
|
# CHECK: 1
|
|
|
|
|
|
|
|
abbr -q __abbr8 banana
|
|
|
|
echo $status
|
|
|
|
# CHECK: 0
|
|
|
|
|
|
|
|
abbr -q banana __abbr8 foobar
|
|
|
|
echo $status
|
|
|
|
# CHECK: 0
|
2022-04-01 19:05:27 +00:00
|
|
|
|
|
|
|
abbr --add grape --position nowhere juice
|
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: Invalid position 'nowhere'
|
|
|
|
# CHECKERR: Position must be one of: command, anywhere.
|
|
|
|
# CHECK: 2
|
|
|
|
|
|
|
|
abbr --add grape --position anywhere juice
|
|
|
|
echo $status
|
|
|
|
# CHECK: 0
|
|
|
|
|
|
|
|
abbr --add grape --position command juice
|
|
|
|
echo $status
|
|
|
|
# CHECK: 0
|
|
|
|
|
|
|
|
abbr --query banana --position anywhere
|
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: --position option requires --add
|
|
|
|
# CHECK: 2
|
2022-07-17 20:27:35 +00:00
|
|
|
|
2022-12-16 16:01:21 +00:00
|
|
|
abbr --query banana --function foo
|
2022-08-06 23:57:26 +00:00
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: --function option requires --add
|
|
|
|
# CHECK: 2
|
|
|
|
|
2022-12-16 16:01:21 +00:00
|
|
|
abbr --query banana --function
|
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: --function: option requires an argument
|
|
|
|
# CHECKERR: checks/abbr.fish (line 141):
|
|
|
|
# CHECKERR: abbr --query banana --function
|
|
|
|
# CHECKERR: ^
|
|
|
|
# CHECKERR: (Type 'help abbr' for related documentation)
|
|
|
|
# CHECK: 2
|
|
|
|
|
2022-08-06 23:57:26 +00:00
|
|
|
abbr --add peach --function invalid/function/name
|
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: Invalid function name: invalid/function/name
|
|
|
|
# CHECK: 2
|
|
|
|
|
|
|
|
# Function names cannot contain spaces, to prevent confusion with fish script.
|
|
|
|
abbr --add peach --function 'no space allowed'
|
|
|
|
echo $status
|
|
|
|
# CHECKERR: abbr: Invalid function name: no space allowed
|
|
|
|
# CHECK: 2
|
|
|
|
|
2022-07-17 20:27:35 +00:00
|
|
|
# Erase all abbreviations
|
|
|
|
abbr --erase (abbr --list)
|
|
|
|
abbr --show
|
|
|
|
# Should be no output
|
|
|
|
|
|
|
|
abbr --add nonregex_name foo
|
|
|
|
abbr --add regex_name --regex 'A[0-9]B' bar
|
2022-12-14 17:06:24 +00:00
|
|
|
abbr --add !! --position anywhere --function replace_history
|
2022-07-17 20:27:35 +00:00
|
|
|
abbr --show
|
|
|
|
# CHECK: abbr -a -- nonregex_name foo
|
2022-12-13 18:38:58 +00:00
|
|
|
# CHECK: abbr -a --regex 'A[0-9]B' -- regex_name bar
|
2022-12-16 16:01:21 +00:00
|
|
|
# CHECK: abbr -a --position anywhere --function replace_history -- !!
|
2023-01-13 15:07:50 +00:00
|
|
|
|
|
|
|
# Confirm that this erases the old uvar
|
|
|
|
# (slightly cheating since we haven't imported it as an abbr,
|
|
|
|
# but that's okay)
|
|
|
|
abbr --erase cuckoo
|
|
|
|
echo erase $status
|
|
|
|
# CHECK: erase 0
|
|
|
|
set --show _fish_abbr_cuckoo
|
|
|
|
# Nothing
|
|
|
|
|
2023-01-13 15:38:34 +00:00
|
|
|
abbr --add '$PAGER' less
|
2022-08-07 20:31:10 +00:00
|
|
|
abbr --erase (abbr --list)
|
2023-01-13 15:38:34 +00:00
|
|
|
abbr --list
|
|
|
|
# Nothing
|
|
|
|
abbr --add '$PAGER' less
|
|
|
|
abbr --list
|
|
|
|
# CHECK: $PAGER
|
2022-08-07 20:31:10 +00:00
|
|
|
|
|
|
|
abbr --add bogus --position never stuff
|
|
|
|
# CHECKERR: abbr: Invalid position 'never'
|
|
|
|
# CHECKERR: Position must be one of: command, anywhere.
|
|
|
|
|
|
|
|
abbr --add bogus --position anywhere --position command stuff
|
|
|
|
# CHECKERR: abbr: Cannot specify multiple positions
|
2023-01-15 09:50:09 +00:00
|
|
|
|
|
|
|
abbr --add --regex foo --function foo
|
|
|
|
# CHECKERR: abbr --add: Name cannot be empty
|
|
|
|
echo foo
|
|
|
|
# CHECK: foo
|
2023-06-20 02:28:35 +00:00
|
|
|
|
|
|
|
abbr --add regex_name --regex '(*UTF).*' bar
|
|
|
|
# CHECKERR: abbr: Regular expression compile error: using UTF is disabled by the application
|
|
|
|
# CHECKERR: abbr: (*UTF).*
|
|
|
|
# CHECKERR: abbr: ^
|