Skip to content

Commit

Permalink
fix bug in cmd line parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
b1f6c1c4 committed Jan 25, 2021
1 parent 2d87c76 commit bee8ea7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion git-get
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ while [ $# -gt 0 ]; do
OUTPUT="${1#-o=}"
elif [[ "$1" =~ ^-o ]]; then
OUTPUT="${1#-o}"
elif [[ "$1" =~ ^- ]]; then
elif [[ "$1" =~ ^-.. ]]; then
T="$1"
shift
set -- '' "${T:0:2}" "-${T:2}" "$@"
elif [[ "$1" =~ ^- ]]; then
echo "Error: Unrecognized argument $1" >&1
exit 1
else
POSITIONAL+=("$1")
fi
Expand Down
9 changes: 8 additions & 1 deletion git-gets
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,10 @@ while [ $# -gt 0 ]; do
NO_RECURSIVE=YES
shift
;;
--flat)
echo "Error: --flat is no longer supported. Please see man git-gets for more information." >&1
exit 1
;;
*)
if [[ "$1" =~ ^-j ]]; then
PARALLEL="${1#-j}"
Expand All @@ -350,10 +354,13 @@ while [ $# -gt 0 ]; do
OUTPUT="${1#-o=}"
elif [[ "$1" =~ ^-o ]]; then
OUTPUT="${1#-o}"
elif [[ "$1" =~ ^- ]]; then
elif [[ "$1" =~ ^-.. ]]; then
T="$1"
shift
set -- '' "${T:0:2}" "-${T:2}" "$@"
elif [[ "$1" =~ ^- ]]; then
echo "Error: Unrecognized argument $1" >&1
exit 1
else
POSITIONAL+=("$1")
fi
Expand Down
2 changes: 2 additions & 0 deletions man/git-get.1
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ make the downloaded repository look as similar as one
created by an ordinary \fBgit clone\fR at the cost of a little bit
more network bandwidth and disk space.
You cannot use it together with \fB-g\fR nor \fB-t\fR.
Besides, you cannot use \fB-- <path>\fR when \fB-x\fR is set.
Specifically, using \fB-x\fR has the following effects:
.IP \[bu] 2
All commits will be downloaded: you can still view the full history
Expand Down Expand Up @@ -104,6 +105,7 @@ cost compared to that with neither of \fB-x\fR nor \fB-g\fR.
However, the actual respository may not be as exploitable as before.
See the discussion of \fB-x\fR to see the difference.
You cannot use it together with \fB-x\fR nor \fB-t\fR.
Besides, you cannot use \fB-- <path>\fR when \fB-g\fR is set.
.RE
.PP
-t, --tag-file=VERSION
Expand Down

0 comments on commit bee8ea7

Please sign in to comment.