Replaced 1..3 range syntax with 1-3 (Inspired by holygeek's git-number project - https://github.com/holygeek/git-number)
This commit is contained in:
@@ -145,27 +145,15 @@ git_expand_args() {
|
|||||||
first=1
|
first=1
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [[ "$arg" =~ ^[0-9]+$ ]] ; then # Substitute $e{*} variables for any integers
|
if [[ "$arg" =~ ^[0-9]+$ ]] ; then # Substitute $e{*} variables for any integers
|
||||||
if [ "$first" -eq 1 ]; then
|
if [ "$first" -eq 1 ]; then first=0; else echo -n " "; fi
|
||||||
first=0
|
|
||||||
else
|
|
||||||
echo -n " "
|
|
||||||
fi
|
|
||||||
eval printf '%s' "\$$git_env_char$arg"
|
eval printf '%s' "\$$git_env_char$arg"
|
||||||
elif [[ "$arg" =~ ^[0-9]+\.\.[0-9]+$ ]]; then # Expand ranges into $e{*} variables
|
elif [[ "$arg" =~ ^[0-9]+-[0-9]+$ ]]; then # Expand ranges into $e{*} variables
|
||||||
for i in $(eval echo {$arg}); do
|
for i in $(eval echo {${arg/-/..}}); do
|
||||||
if [ "$first" -eq 1 ]; then
|
if [ "$first" -eq 1 ]; then first=0; else echo -n " "; fi
|
||||||
first=0
|
|
||||||
else
|
|
||||||
echo -n " "
|
|
||||||
fi
|
|
||||||
eval printf '%s' "\$$git_env_char$i"
|
eval printf '%s' "\$$git_env_char$i"
|
||||||
done
|
done
|
||||||
else # Otherwise, treat $arg as a normal string.
|
else # Otherwise, treat $arg as a normal string.
|
||||||
if [ "$first" -eq 1 ]; then
|
if [ "$first" -eq 1 ]; then first=0; else echo -n " "; fi
|
||||||
first=0
|
|
||||||
else
|
|
||||||
echo -n " "
|
|
||||||
fi
|
|
||||||
printf '%q' "$arg"
|
printf '%q' "$arg"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -51,8 +51,8 @@ test_git_expand_args() {
|
|||||||
local e1="one"; local e2="two"; local e3="three"; local e4="four"; local e5="five"; local e6="six"; local e7="seven"
|
local e1="one"; local e2="two"; local e3="three"; local e4="four"; local e5="five"; local e6="six"; local e7="seven"
|
||||||
local error="Args not expanded correctly"
|
local error="Args not expanded correctly"
|
||||||
assertEquals "$error" "one three seven" "$(git_expand_args 1 3 7)"
|
assertEquals "$error" "one three seven" "$(git_expand_args 1 3 7)"
|
||||||
assertEquals "$error" "one two three six" "$(git_expand_args 1..3 6)"
|
assertEquals "$error" "one two three six" "$(git_expand_args 1-3 6)"
|
||||||
assertEquals "$error" "seven two three four five one" "$(git_expand_args seven 2..5 1)"
|
assertEquals "$error" "seven two three four five one" "$(git_expand_args seven 2-5 1)"
|
||||||
|
|
||||||
# Test that any args with spaces remain quoted
|
# Test that any args with spaces remain quoted
|
||||||
assertEquals "$error" "-m Test\ Commit\ Message one" "$(git_expand_args -m "Test Commit Message" 1)"
|
assertEquals "$error" "-m Test\ Commit\ Message one" "$(git_expand_args -m "Test Commit Message" 1)"
|
||||||
@@ -218,7 +218,7 @@ test_git_add_shortcuts() {
|
|||||||
touch a b c d e f g h i j
|
touch a b c d e f g h i j
|
||||||
# Show git status, which sets up env variables
|
# Show git status, which sets up env variables
|
||||||
git_status_shortcuts > /dev/null
|
git_status_shortcuts > /dev/null
|
||||||
git_add_shortcuts 2..4 7 8 > /dev/null
|
git_add_shortcuts 2-4 7 8 > /dev/null
|
||||||
git_status=$(git_status_shortcuts 1 | strip_colors)
|
git_status=$(git_status_shortcuts 1 | strip_colors)
|
||||||
|
|
||||||
for c in b c d g h; do
|
for c in b c d g h; do
|
||||||
|
|||||||
Reference in New Issue
Block a user