Skip to content

Commit ad4c003

Browse files
committed
use while -v loop instead of for arg in
this is more robust and doesn't require extra handling
1 parent fd61260 commit ad4c003

6 files changed

Lines changed: 30 additions & 84 deletions

File tree

diamonddb.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,9 @@ syslog=no
8989
debug=no
9090
verbose=no
9191

92-
ignore_next_arg=no
93-
94-
for arg in "$@"
92+
while [[ -v 1 ]]
9593
do
96-
if [[ $ignore_next_arg == yes ]]
97-
then
98-
ignore_next_arg=no
99-
continue
100-
fi
101-
102-
case "$arg" in
94+
case "$1" in
10395
-\?|--help)
10496
usage
10597
exit
@@ -115,7 +107,6 @@ do
115107
cores=${1:?"parallel option has no argument"}
116108
[[ $cores =~ ^[0-9]+$ ]] ||
117109
bailout "parallel option argument is not a number: $cores"
118-
ignore_next_arg=yes
119110
shift
120111
;;
121112

@@ -145,7 +136,7 @@ do
145136
;;
146137

147138
--debug=yes|--debug=no)
148-
debug=${arg##--debug=}
139+
debug=${1##--debug=}
149140
shift
150141
;;
151142

@@ -161,7 +152,7 @@ do
161152
;;
162153

163154
--verbose=yes|--verbose=no)
164-
verbose=${arg##--verbose=}
155+
verbose=${1##--verbose=}
165156
shift
166157
;;
167158

@@ -171,7 +162,7 @@ do
171162
;;
172163

173164
-*)
174-
bailout "unrecognized option: $arg"
165+
bailout "unrecognized option: $1"
175166
;;
176167

177168
*)

ebidl.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,9 @@ syslog=no
7979
debug=no
8080
verbose=no
8181

82-
ignore_next_arg=no
83-
84-
for arg in "$@"
82+
while [[ -v 1 ]]
8583
do
86-
if [[ $ignore_next_arg == yes ]]
87-
then
88-
ignore_next_arg=no
89-
continue
90-
fi
91-
92-
case "$arg" in
84+
case "$1" in
9385
-\?|--help)
9486
usage
9587
exit
@@ -105,7 +97,6 @@ do
10597
cores=${1:?"parallel option has no argument"}
10698
[[ $cores =~ ^[0-9]+$ ]] ||
10799
bailout "parallel option argument is not a number: $cores"
108-
ignore_next_arg=yes
109100
shift
110101
;;
111102

@@ -135,7 +126,7 @@ do
135126
;;
136127

137128
--debug=yes|--debug=no)
138-
debug=${arg##--debug=}
129+
debug=${1##--debug=}
139130
shift
140131
;;
141132

@@ -151,7 +142,7 @@ do
151142
;;
152143

153144
--verbose=yes|--verbose=no)
154-
verbose=${arg##--verbose=}
145+
verbose=${1##--verbose=}
155146
shift
156147
;;
157148

@@ -161,7 +152,7 @@ do
161152
;;
162153

163154
-*)
164-
bailout "unrecognized option: $arg"
155+
bailout "unrecognized option: $1"
165156
;;
166157

167158
*)

ensembldl.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,9 @@ debug=no
8181
verbose=no
8282
ensembl_server="ensembl"
8383

84-
ignore_next_arg=no
85-
86-
for arg in "$@"
84+
while [[ -v 1 ]]
8785
do
88-
if [[ $ignore_next_arg == yes ]]
89-
then
90-
ignore_next_arg=no
91-
continue
92-
fi
93-
94-
case "$arg" in
86+
case "$1" in
9587
-\?|--help)
9688
usage
9789
exit
@@ -112,7 +104,6 @@ do
112104
cores=${1:?"parallel option has no argument"}
113105
[[ $cores =~ ^[0-9]+$ ]] ||
114106
bailout "parallel option argument is not a number: $cores"
115-
ignore_next_arg=yes
116107
shift
117108
;;
118109

@@ -142,7 +133,7 @@ do
142133
;;
143134

144135
--debug=yes|--debug=no)
145-
debug=${arg##--debug=}
136+
debug=${1##--debug=}
146137
shift
147138
;;
148139

@@ -158,7 +149,7 @@ do
158149
;;
159150

160151
--verbose=yes|--verbose=no)
161-
verbose=${arg##--verbose=}
152+
verbose=${1##--verbose=}
162153
shift
163154
;;
164155

@@ -168,7 +159,7 @@ do
168159
;;
169160

170161
-*)
171-
bailout "unrecognized option: $arg"
162+
bailout "unrecognized option: $1"
172163
;;
173164

174165
*)

ncbidl.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,9 @@ syslog=no
7979
debug=no
8080
verbose=no
8181

82-
ignore_next_arg=no
83-
84-
for arg in "$@"
82+
while [[ -v 1 ]]
8583
do
86-
if [[ $ignore_next_arg == yes ]]
87-
then
88-
ignore_next_arg=no
89-
continue
90-
fi
91-
92-
case "$arg" in
84+
case "$1" in
9385
-\?|--help)
9486
usage
9587
exit
@@ -105,7 +97,6 @@ do
10597
cores=${1:?"parallel option has no argument"}
10698
[[ $cores =~ ^[0-9]+$ ]] ||
10799
bailout "parallel option argument is not a number: $cores"
108-
ignore_next_arg=yes
109100
shift
110101
;;
111102

@@ -135,7 +126,7 @@ do
135126
;;
136127

137128
--debug=yes|--debug=no)
138-
debug=${arg##--debug=}
129+
debug=${1##--debug=}
139130
shift
140131
;;
141132

@@ -151,7 +142,7 @@ do
151142
;;
152143

153144
--verbose=yes|--verbose=no)
154-
verbose=${arg##--verbose=}
145+
verbose=${1##--verbose=}
155146
shift
156147
;;
157148

@@ -161,7 +152,7 @@ do
161152
;;
162153

163154
-*)
164-
bailout "unrecognized option: $arg"
155+
bailout "unrecognized option: $1"
165156
;;
166157

167158
*)

ucscdl.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,9 @@ syslog=no
7979
debug=no
8080
verbose=no
8181

82-
ignore_next_arg=no
83-
84-
for arg in "$@"
82+
while [[ -v 1 ]]
8583
do
86-
if [[ $ignore_next_arg == yes ]]
87-
then
88-
ignore_next_arg=no
89-
continue
90-
fi
91-
92-
case "$arg" in
84+
case "$1" in
9385
-\?|--help)
9486
usage
9587
exit
@@ -105,7 +97,6 @@ do
10597
cores=${1:?"parallel option has no argument"}
10698
[[ $cores =~ ^[0-9]+$ ]] ||
10799
bailout "parallel option argument is not a number: $cores"
108-
ignore_next_arg=yes
109100
shift
110101
;;
111102

@@ -135,7 +126,7 @@ do
135126
;;
136127

137128
--debug=yes|--debug=no)
138-
debug=${arg##--debug=}
129+
debug=${1##--debug=}
139130
shift
140131
;;
141132

@@ -151,7 +142,7 @@ do
151142
;;
152143

153144
--verbose=yes|--verbose=no)
154-
verbose=${arg##--verbose=}
145+
verbose=${1##--verbose=}
155146
shift
156147
;;
157148

@@ -161,7 +152,7 @@ do
161152
;;
162153

163154
-*)
164-
bailout "unrecognized option: $arg"
155+
bailout "unrecognized option: $1"
165156
;;
166157

167158
*)

uniprotdl.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,9 @@ syslog=no
7979
debug=no
8080
verbose=no
8181

82-
ignore_next_arg=no
83-
84-
for arg in "$@"
82+
while [[ -v 1 ]]
8583
do
86-
if [[ $ignore_next_arg == yes ]]
87-
then
88-
ignore_next_arg=no
89-
continue
90-
fi
91-
92-
case "$arg" in
84+
case "$1" in
9385
-\?|--help)
9486
usage
9587
exit
@@ -105,7 +97,6 @@ do
10597
cores=${1:?"parallel option has no argument"}
10698
[[ $cores =~ ^[0-9]+$ ]] ||
10799
bailout "parallel option argument is not a number: $cores"
108-
ignore_next_arg=yes
109100
shift
110101
;;
111102

@@ -135,7 +126,7 @@ do
135126
;;
136127

137128
--debug=yes|--debug=no)
138-
debug=${arg##--debug=}
129+
debug=${1##--debug=}
139130
shift
140131
;;
141132

@@ -151,7 +142,7 @@ do
151142
;;
152143

153144
--verbose=yes|--verbose=no)
154-
verbose=${arg##--verbose=}
145+
verbose=${1##--verbose=}
155146
shift
156147
;;
157148

@@ -161,7 +152,7 @@ do
161152
;;
162153

163154
-*)
164-
bailout "unrecognized option: $arg"
155+
bailout "unrecognized option: $1"
165156
;;
166157

167158
*)

0 commit comments

Comments
 (0)