fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
99d63c21f
master
1#RUN: %fish %s 2 3# Universal abbreviations are imported. 4set -U _fish_abbr_cuckoo somevalue 5set fish( status fish-path) 6$fish -c abbr 7# CHECK: abbr -a -- cuckoo somevalue # imported from a universal variable, see `help cmds/abbr` 8 9# Test basic add and list of __abbr1 10abbr __abbr1 alpha beta gamma 11abbr | grep __abbr1 12# CHECK: abbr -a -- __abbr1 'alpha beta gamma' 13 14# Erasing one that doesn\'t exist should do nothing 15abbr --erase NOT_AN_ABBR 16abbr | grep __abbr1 17# CHECK: abbr -a -- __abbr1 'alpha beta gamma' 18 19# Adding existing __abbr1 should be idempotent 20abbr __abbr1 alpha beta gamma 21abbr | grep __abbr1 22# CHECK: abbr -a -- __abbr1 'alpha beta gamma' 23 24# Replacing __abbr1 definition 25abbr __abbr1 delta 26abbr | grep __abbr1 27# CHECK: abbr -a -- __abbr1 delta 28 29# __abbr1 -s and --show tests 30abbr -s| grep __abbr1 31abbr --show| grep __abbr1 32# CHECK: abbr -a -- __abbr1 delta 33# CHECK: abbr -a -- __abbr1 delta 34 35# Test erasing __abbr1 36abbr -e __abbr1 37abbr | grep __abbr1 38 39# Ensure we escape special characters on output 40abbr '~__abbr2' '$xyz' 41abbr | grep __abbr2 42# CHECK: abbr -a -- '~__abbr2' '$xyz' 43abbr -e'~__abbr2' 44 45# Ensure we handle leading dashes in abbreviation names properly 46abbr -- --__abbr3 xyz 47abbr | grep __abbr3 48# CHECK: abbr -a -- --__abbr3 xyz 49abbr -e -- --__abbr3 50 51# Test that an abbr word containing spaces is rejected 52abbr "a b c" "d e f" 53abbr | grep 'a b c' 54# CHECKERR: abbr --add: Abbreviation 'a b c' cannot have spaces in the word 55 56# Test renaming 57abbr __abbr4 omega 58abbr | grep __abbr5 59abbr --rename __abbr4 __abbr5 60abbr | grep __abbr5 61# CHECK: abbr -a -- __abbr5 omega 62abbr -e __abbr5 63abbr | grep __abbr4 64 65# Test renaming a nonexistent abbreviation 66abbr --rename __abbr6 __abbr 67# CHECKERR: abbr --rename: No abbreviation named __abbr6 with the specified command restrictions 68 69# Test renaming to a abbreviation with spaces 70abbr __abbr4 omega 71abbr --rename __abbr4"g h i" 72# CHECKERR: abbr --rename: Abbreviation 'g h i' cannot have spaces in the word 73abbr -e __abbr4 74 75# Test renaming without arguments 76abbr __abbr7 omega 77abbr --rename __abbr7 78# CHECKERR: abbr --rename: Requires exactly two arguments 79 80# Test renaming with too many arguments 81abbr __abbr8 omega 82abbr --rename __abbr8 __abbr9 __abbr10 83# CHECKERR: abbr --rename: Requires exactly two arguments 84abbr | grep __abbr8 85abbr | grep __abbr9 86abbr | grep __abbr10 87# CHECK: abbr -a -- __abbr8 omega 88 89# Test renaming to existing abbreviation 90abbr __abbr11 omega11 91abbr __abbr12 omega12 92abbr --rename __abbr11 __abbr12 93# CHECKERR: abbr --rename: Abbreviation __abbr12 already exists, cannot rename __abbr11 94 95abbr __abbr-with-dashes omega 96complete -C__abbr-with 97# CHECK: __abbr-with-dashes Abbreviation: omega 98 99abbr --add --global __abbr13 aaaaaaaaaaaaa 100abbr --add --global __abbr14 bbbbbbbbbbbbb 101abbr --erase __abbr13 __abbr14 102abbr | grep __abbr13 103abbr | grep __abbr14 104 105abbr -q banana 106echo $status 107# CHECK: 1 108 109abbr -q __abbr8 banana 110echo $status 111# CHECK: 0 112 113abbr -q banana __abbr8 foobar 114echo $status 115# CHECK: 0 116 117abbr --add grape --position nowhere juice 118echo $status 119# CHECKERR: abbr: Invalid position 'nowhere' 120# CHECKERR: Position must be one of: command, anywhere 121# CHECK: 2 122 123abbr --add grape --position anywhere juice 124echo $status 125# CHECK: 0 126 127abbr --add grape --position command juice 128echo $status 129# CHECK: 0 130 131abbr --query banana --position anywhere 132echo $status 133# CHECKERR: abbr: --position option requires --add 134# CHECK: 2 135 136abbr --query banana --function foo 137echo $status 138# CHECKERR: abbr: --function option requires --add 139# CHECK: 2 140 141abbr --query banana --function 142echo $status 143# CHECKERR: abbr: --function: option requires an argument 144# CHECKERR: {{.*}}checks/abbr.fish (line 141): 145# CHECKERR: abbr --query banana --function 146# CHECKERR: ^ 147# CHECKERR: (Type 'help abbr' for related documentation) 148# CHECK: 2 149 150abbr --add peach --function invalid/function/name 151echo $status 152# CHECKERR: abbr: Invalid function name: invalid/function/name 153# CHECK: 2 154 155# Function names cannot contain spaces, to prevent confusion with fish script. 156abbr --add peach --function'no space allowed' 157echo $status 158# CHECKERR: abbr: Invalid function name: no space allowed 159# CHECK: 2 160 161# Erase all abbreviations 162abbr --erase( abbr --list) 163abbr --show 164# Should be no output 165 166abbr --add nonregex_name foo 167abbr --add regex_name --regex'A[0-9]B' bar 168abbr --add !! --position anywhere --function replace_history 169abbr --show 170# CHECK: abbr -a -- nonregex_name foo 171# CHECK: abbr -a --regex 'A[0-9]B' -- regex_name bar 172# CHECK: abbr -a --position anywhere --function replace_history -- !! 173 174# Confirm that this erases the old uvar 175# (slightly cheating since we haven't imported it as an abbr, 176# but that's okay) 177abbr --erase cuckoo 178echo erase$status 179# CHECK: erase 0 180set --show _fish_abbr_cuckoo 181# Nothing 182 183abbr --add'$PAGER' less 184abbr --erase( abbr --list) 185abbr --list 186# Nothing 187abbr --add'$PAGER' less 188abbr --list 189# CHECK: $PAGER 190 191abbr --add bogus --position never stuff 192# CHECKERR: abbr: Invalid position 'never' 193# CHECKERR: Position must be one of: command, anywhere 194 195abbr --add bogus --position anywhere --position command stuff 196# CHECKERR: abbr: Cannot specify multiple positions 197 198abbr --add --regex foo --function foo 199# CHECKERR: abbr --add: Name cannot be empty 200echo foo 201# CHECK: foo 202 203abbr --add regex_name --regex'(*UTF).*' bar 204# CHECKERR: abbr: Regular expression compile error: using UTF is disabled by the application 205# CHECKERR: abbr: (*UTF).* 206# CHECKERR: abbr: ^ 207 208abbr --add foo --set-cursor'foo % bar' 209abbr | grep foo 210# CHECK: abbr -a --set-cursor='%' -- foo 'foo % bar' 211 212# Command-specific and general abbrs can coexist 213abbr __abbr_coexist"general def" 214abbr --command foo __abbr_coexist"command def" 215abbr | grep __abbr_coexist 216# CHECK: abbr -a -- __abbr_coexist 'general def' 217# CHECK: abbr -a --position anywhere --command foo -- __abbr_coexist 'command def' 218 219# Erase general abbreviation 220abbr -e __abbr_coexist 221abbr | grep __abbr_coexist 222# CHECK: abbr -a --position anywhere --command foo -- __abbr_coexist 'command def' 223 224# Abbrs with different commands coexist 225abbr --command bar __abbr_coexist"bar command" 226abbr | grep __abbr_coexist 227# CHECK: abbr -a --position anywhere --command foo -- __abbr_coexist 'command def' 228# CHECK: abbr -a --position anywhere --command bar -- __abbr_coexist 'bar command' 229 230# Rename command-specific abbr 231abbr --rename --command bar __abbr_coexist __abbr_coexist_2 232abbr | grep __abbr_coexist 233# CHECK: abbr -a --position anywhere --command foo -- __abbr_coexist 'command def' 234# CHECK: abbr -a --position anywhere --command bar -- __abbr_coexist_2 'bar command' 235abbr -e --command foo __abbr_coexist 236abbr -e --command bar __abbr_coexist_2 237 238abbr --add foo --rename foo fuu --show --list --erase foo --query foo 239# CHECKERR: abbr: Cannot combine options add, rename, show, list, erase, query 240 241abbr --add foo 242# CHECKERR: abbr --add: Requires at least two arguments 243 244abbr --add foo --function foobar extra 245# CHECKERR: abbr: too many arguments 246 247abbr --add foo --command=foobar --position=command bar 248# CHECKERR: abbr: --command cannot be combined with --position=command 249 250abbr --list --regex"." 251# CHECKERR: abbr: --regex option requires --add 252 253abbr --add --regex"a." --regex".b" foo bar 254# CHECKERR: abbr: Cannot specify multiple regex patterns 255 256abbr --show --set-cursor=marker 257# CHECKERR: abbr: --set-cursor option requires --add 258 259abbr --add --set-cursor=marker --set-cursor=marker 260# CHECKERR: abbr: Cannot specify multiple set-cursor options 261 262abbr --add foo --set-cursor= foo 263# CHECKERR: abbr: --set-cursor argument cannot be empty 264 265abbr --list foo 266# CHECKERR: abbr --list: Unexpected argument -- 'foo' 267 268abbr --rename"" bar 269# CHECKERR: abbr --rename: Name cannot be empty 270 271abbr --rename foo"" 272# CHECKERR: abbr --rename: Name cannot be empty 273 274abbr sub1 -c foo -c bar foo_1 275abbr sub2 -c foo -c bar foo_1 276abbr --rename -c foo -c bar sub1 sub2 277# CHECKERR: abbr --rename: Abbreviation sub2 already exists for commands foo, bar, cannot rename sub1 278abbr --erase sub1 --command={ foo, bar} 279abbr --erase sub2 --command={ foo, bar} 280 281abbr --erase( abbr --list) 282abbr -U 283# CHECKERR: abbr: Warning: Option '-U' was removed and is now ignored 284# CHECKERR: {{.*}}checks/abbr.fish (line {{\d+}}): 285# CHECKERR: abbr -U 286# CHECKERR: ^ 287# CHECKERR: (Type 'help abbr' for related documentation)