Add the possibility to rename abbreviations

The abbr function doesn't have the possiblity to rename abbreviations.
You have to delete the old one and create a new one. This commit adds
this functionality and uses the syntax:

abbr -r OLD_KEY NEW_KEY

Fixes #2155.
This commit is contained in:
Radomír Bosák
2016-12-01 22:19:48 +01:00
committed by Kurtis Rader
parent a0d9db94cb
commit 1fbcb1ee9d
5 changed files with 89 additions and 0 deletions

View File

@@ -1,2 +1,7 @@
abbr: no such abbreviation 'NOT_AN_ABBR'
abbr: abbreviation cannot have spaces in the key
abbr: no such abbreviation '__abbr6'
abbr: abbreviation cannot have spaces in the key
abbr: option requires an argument -- -r
abbr: Unexpected argument -- __abbr10
abbr: abbreviation '__abbr12' already exists, cannot rename

View File

@@ -37,3 +37,35 @@ abbr d2 env a=b banana
abbr -l | string match -q d2; or echo "= test failed"
abbr "a b c" "d e f"; or true
# 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

View File

@@ -6,3 +6,5 @@ abbr __abbr1 delta
abbr __abbr1 delta
abbr '~__abbr2' '$xyz'
abbr -- --__abbr3 xyz
abbr __abbr5 omega
abbr __abbr8 omega