Skip to content

Commit 5a69fed

Browse files
committed
Makes -- optional unless args reference a file
1 parent fa99c42 commit 5a69fed

15 files changed

+195
-60
lines changed

go-build-mod.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,35 @@ function find_module_roots() {
2323
done
2424
}
2525

26+
OPTIONS=()
27+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
28+
#
29+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
30+
OPTIONS+=("$1")
31+
shift
32+
done
33+
2634
FILES=()
27-
# Build potential options list (may just be files)
35+
# Assume start of file list (may still be options)
2836
#
2937
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
3038
FILES+=("$1")
3139
shift
3240
done
3341

34-
OPTIONS=()
3542
# If '--' next, then files = options
3643
#
3744
if [ $# -gt 0 ]; then
3845
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
3946
shift
40-
OPTIONS=("${FILES[@]}")
47+
# Append to previous options
48+
#
49+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
4150
FILES=()
4251
fi
4352
fi
4453

45-
# Any remaining items are files
54+
# Any remaining arguments are assumed to be files
4655
#
4756
while [ $# -gt 0 ]; do
4857
FILES+=("$1")

go-build-pkg.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@ cmd=(go build -o /dev/null)
44

55
export GO111MODULE=off
66

7+
OPTIONS=()
8+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
9+
#
10+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
11+
OPTIONS+=("$1")
12+
shift
13+
done
14+
715
FILES=()
8-
# Build potential options list (may just be files)
16+
# Assume start of file list (may still be options)
917
#
1018
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
1119
FILES+=("$1")
1220
shift
1321
done
1422

15-
OPTIONS=()
1623
# If '--' next, then files = options
1724
#
1825
if [ $# -gt 0 ]; then
1926
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
2027
shift
21-
OPTIONS=("${FILES[@]}")
28+
# Append to previous options
29+
#
30+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2231
FILES=()
2332
fi
2433
fi
2534

26-
# Any remaining items are files
35+
# Any remaining arguments are assumed to be files
2736
#
2837
while [ $# -gt 0 ]; do
2938
FILES+=("$1")

go-critic.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
cmd=(gocritic check)
44

5+
OPTIONS=()
6+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
7+
#
8+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
9+
OPTIONS+=("$1")
10+
shift
11+
done
12+
513
FILES=()
6-
# Build potential options list (may just be files)
14+
# Assume start of file list (may still be options)
715
#
816
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
917
FILES+=("$1")
1018
shift
1119
done
1220

13-
OPTIONS=()
1421
# If '--' next, then files = options
1522
#
1623
if [ $# -gt 0 ]; then
1724
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
1825
shift
19-
OPTIONS=("${FILES[@]}")
26+
# Append to previous options
27+
#
28+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2029
FILES=()
2130
fi
2231
fi
2332

24-
# Any remaining items are files
33+
# Any remaining arguments are assumed to be files
2534
#
2635
while [ $# -gt 0 ]; do
2736
FILES+=("$1")

go-fmt.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
cmd=(gofmt -l -d)
44

5+
OPTIONS=()
6+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
7+
#
8+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
9+
OPTIONS+=("$1")
10+
shift
11+
done
12+
513
FILES=()
6-
# Build potential options list (may just be files)
14+
# Assume start of file list (may still be options)
715
#
816
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
917
FILES+=("$1")
1018
shift
1119
done
1220

13-
OPTIONS=()
1421
# If '--' next, then files = options
1522
#
1623
if [ $# -gt 0 ]; then
1724
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
1825
shift
19-
OPTIONS=("${FILES[@]}")
26+
# Append to previous options
27+
#
28+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2029
FILES=()
2130
fi
2231
fi
2332

24-
# Any remaining items are files
33+
# Any remaining arguments are assumed to be files
2534
#
2635
while [ $# -gt 0 ]; do
2736
FILES+=("$1")

go-imports.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
cmd=(goimports -l -d)
44

5+
OPTIONS=()
6+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
7+
#
8+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
9+
OPTIONS+=("$1")
10+
shift
11+
done
12+
513
FILES=()
6-
# Build potential options list (may just be files)
14+
# Assume start of file list (may still be options)
715
#
816
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
917
FILES+=("$1")
1018
shift
1119
done
1220

13-
OPTIONS=()
1421
# If '--' next, then files = options
1522
#
1623
if [ $# -gt 0 ]; then
1724
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
1825
shift
19-
OPTIONS=("${FILES[@]}")
26+
# Append to previous options
27+
#
28+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2029
FILES=()
2130
fi
2231
fi
2332

24-
# Any remaining items are files
33+
# Any remaining arguments are assumed to be files
2534
#
2635
while [ $# -gt 0 ]; do
2736
FILES+=("$1")

go-lint.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
cmd=(golint -set_exit_status)
44

5+
OPTIONS=()
6+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
7+
#
8+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
9+
OPTIONS+=("$1")
10+
shift
11+
done
12+
513
FILES=()
6-
# Build potential options list (may just be files)
14+
# Assume start of file list (may still be options)
715
#
816
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
917
FILES+=("$1")
1018
shift
1119
done
1220

13-
OPTIONS=()
1421
# If '--' next, then files = options
1522
#
1623
if [ $# -gt 0 ]; then
1724
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
1825
shift
19-
OPTIONS=("${FILES[@]}")
26+
# Append to previous options
27+
#
28+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2029
FILES=()
2130
fi
2231
fi
2332

24-
# Any remaining items are files
33+
# Any remaining arguments are assumed to be files
2534
#
2635
while [ $# -gt 0 ]; do
2736
FILES+=("$1")

go-returns.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@
22

33
cmd=(goreturns -l -d)
44

5+
OPTIONS=()
6+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
7+
#
8+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
9+
OPTIONS+=("$1")
10+
shift
11+
done
12+
513
FILES=()
6-
# Build potential options list (may just be files)
14+
# Assume start of file list (may still be options)
715
#
816
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
917
FILES+=("$1")
1018
shift
1119
done
1220

13-
OPTIONS=()
1421
# If '--' next, then files = options
1522
#
1623
if [ $# -gt 0 ]; then
1724
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
1825
shift
19-
OPTIONS=("${FILES[@]}")
26+
# Append to previous options
27+
#
28+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2029
FILES=()
2130
fi
2231
fi
2332

24-
# Any remaining items are files
33+
# Any remaining arguments are assumed to be files
2534
#
2635
while [ $# -gt 0 ]; do
2736
FILES+=("$1")

go-test-mod.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,35 @@ function find_module_roots() {
2323
done
2424
}
2525

26+
OPTIONS=()
27+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
28+
#
29+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
30+
OPTIONS+=("$1")
31+
shift
32+
done
33+
2634
FILES=()
27-
# Build potential options list (may just be files)
35+
# Assume start of file list (may still be options)
2836
#
2937
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
3038
FILES+=("$1")
3139
shift
3240
done
3341

34-
OPTIONS=()
3542
# If '--' next, then files = options
3643
#
3744
if [ $# -gt 0 ]; then
3845
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
3946
shift
40-
OPTIONS=("${FILES[@]}")
47+
# Append to previous options
48+
#
49+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
4150
FILES=()
4251
fi
4352
fi
4453

45-
# Any remaining items are files
54+
# Any remaining arguments are assumed to be files
4655
#
4756
while [ $# -gt 0 ]; do
4857
FILES+=("$1")

go-test-pkg.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,35 @@ cmd=(go test)
44

55
export GO111MODULE=off
66

7+
OPTIONS=()
8+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
9+
#
10+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
11+
OPTIONS+=("$1")
12+
shift
13+
done
14+
715
FILES=()
8-
# Build potential options list (may just be files)
16+
# Assume start of file list (may still be options)
917
#
1018
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
1119
FILES+=("$1")
1220
shift
1321
done
1422

15-
OPTIONS=()
1623
# If '--' next, then files = options
1724
#
1825
if [ $# -gt 0 ]; then
1926
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
2027
shift
21-
OPTIONS=("${FILES[@]}")
28+
# Append to previous options
29+
#
30+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
2231
FILES=()
2332
fi
2433
fi
2534

26-
# Any remaining items are files
35+
# Any remaining arguments are assumed to be files
2736
#
2837
while [ $# -gt 0 ]; do
2938
FILES+=("$1")

go-vet-mod.sh

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,35 @@ function find_module_roots() {
2323
done
2424
}
2525

26+
OPTIONS=()
27+
# If arg doesn't pass [ -f ] check, then it is assumed to be an option
28+
#
29+
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ] && [ ! -f "$1" ]; do
30+
OPTIONS+=("$1")
31+
shift
32+
done
33+
2634
FILES=()
27-
# Build potential options list (may just be files)
35+
# Assume start of file list (may still be options)
2836
#
2937
while [ $# -gt 0 ] && [ "$1" != "-" ] && [ "$1" != "--" ]; do
3038
FILES+=("$1")
3139
shift
3240
done
3341

34-
OPTIONS=()
3542
# If '--' next, then files = options
3643
#
3744
if [ $# -gt 0 ]; then
3845
if [ "$1" == "-" ] || [ "$1" == "--" ]; then
3946
shift
40-
OPTIONS=("${FILES[@]}")
47+
# Append to previous options
48+
#
49+
OPTIONS=("${OPTIONS[@]}" "${FILES[@]}")
4150
FILES=()
4251
fi
4352
fi
4453

45-
# Any remaining items are files
54+
# Any remaining arguments are assumed to be files
4655
#
4756
while [ $# -gt 0 ]; do
4857
FILES+=("$1")

0 commit comments

Comments
 (0)