2015-06-14 21:13:57 +00:00
|
|
|
# Test basic add and list
|
|
|
|
abbr __abbr1 alpha beta gamma
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# Erasing one that doesn't exist should do nothing
|
|
|
|
abbr --erase NOT_AN_ABBR
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# Adding existing one should be idempotent
|
|
|
|
abbr __abbr1 alpha beta gamma
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# Replacing
|
|
|
|
abbr __abbr1 delta
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# -s and --show tests
|
|
|
|
abbr -s | grep __abbr1
|
|
|
|
abbr --show | grep __abbr1
|
|
|
|
|
|
|
|
# Test erasing
|
|
|
|
abbr -e __abbr1
|
|
|
|
abbr | grep __abbr1
|
|
|
|
|
|
|
|
# Ensure we escape special characters on output
|
|
|
|
abbr '~__abbr2' '$xyz'
|
|
|
|
abbr | grep __abbr2
|
|
|
|
abbr -e '~__abbr2'
|
|
|
|
|
|
|
|
# Ensure we handle leading dashes in abbreviation names properly
|
|
|
|
abbr -- '--__abbr3' 'xyz'
|
|
|
|
abbr | grep __abbr3
|
2016-05-23 18:19:22 +00:00
|
|
|
abbr -e -- '--__abbr3'
|
2016-01-07 20:32:16 +00:00
|
|
|
|
|
|
|
# Ensure we are not recognizing later "=" as separators
|
|
|
|
abbr d2 env a=b banana
|
|
|
|
abbr -l | string match -q d2; or echo "= test failed"
|
2016-05-19 14:48:45 +00:00
|
|
|
|
|
|
|
abbr "a b c" "d e f"; or true
|
2016-12-01 21:19:48 +00:00
|
|
|
|
|
|
|
# Test renaming
|
|
|
|
abbr __abbr4 omega
|
|
|
|
abbr | grep __abbr5
|
|
|
|
abbr -r __abbr4 __abbr5
|
|
|
|
abbr | grep __abbr5
|
|
|
|
abbr -e __abbr5
|
|
|
|
abbr | grep __abbr4
|
|
|
|
|
|
|
|
# Test renaming a nonexistent abbreviation
|
|
|
|
abbr -r __abbr6 __abbr; or true
|
|
|
|
|
|
|
|
# Test renaming to a abbreviation with spaces
|
|
|
|
abbr __abbr4 omega
|
|
|
|
abbr -r __abbr4 "g h i"; or true
|
|
|
|
abbr -e __abbr4
|
|
|
|
|
|
|
|
# Test renaming without arguments
|
|
|
|
abbr __abbr7 omega
|
|
|
|
abbr -r __abbr7; or true
|
|
|
|
|
|
|
|
# Test renaming with too many arguments
|
|
|
|
abbr __abbr8 omega
|
|
|
|
abbr -r __abbr8 __abbr9 __abbr10; or true
|
|
|
|
abbr | grep __abbr8
|
|
|
|
abbr | grep __abbr9; or true
|
|
|
|
abbr | grep __abbr10; or true
|
|
|
|
|
|
|
|
# Test renaming to existing abbreviation
|
|
|
|
abbr __abbr11 omega11
|
|
|
|
abbr __abbr12 omega12
|
|
|
|
abbr -r __abbr11 __abbr12; or true
|