Mercurial > mplayer.hg
comparison TOOLS/checktree.sh @ 23948:66a261a0e0f2
Much smaller command line parser
This removes all code duplication for setting and unsetting -(no)flags specified
on the command line
author | ivo |
---|---|
date | Tue, 31 Jul 2007 14:48:13 +0000 |
parents | 1b3e61a77754 |
children | 26db94620073 |
comparison
equal
deleted
inserted
replaced
23947:afce92865498 | 23948:66a261a0e0f2 |
---|---|
24 # of a source-tree checker and Torinthiel for the feedback along the way. | 24 # of a source-tree checker and Torinthiel for the feedback along the way. |
25 | 25 |
26 # $Id$ | 26 # $Id$ |
27 | 27 |
28 # ----------------------------------------------------------------------------- | 28 # ----------------------------------------------------------------------------- |
29 | |
30 # All yes/no flags. Spaces around flagnames are important! | |
31 | |
32 testflags=" spaces extensions crlf tabs trailws rcsid oll charset stupid gnu \ | |
33 res " | |
34 allflags="$testflags showcont color head svn " | |
29 | 35 |
30 # Default settings | 36 # Default settings |
31 | 37 |
32 _spaces=yes | 38 _spaces=yes |
33 _extensions=yes | 39 _extensions=yes |
139 "use svn info to determine which files to check" "$_svn" | 145 "use svn info to determine which files to check" "$_svn" |
140 echo -e "\nIf no files are specified, the whole tree is traversed." | 146 echo -e "\nIf no files are specified, the whole tree is traversed." |
141 echo -e "If there are, -(no)svn has no effect.\n" | 147 echo -e "If there are, -(no)svn has no effect.\n" |
142 exit | 148 exit |
143 ;; | 149 ;; |
144 -stupid) | |
145 _stupid=yes | |
146 ;; | |
147 -nostupid) | |
148 _stupid=no | |
149 ;; | |
150 -charset) | |
151 _charset=yes | |
152 ;; | |
153 -nocharset) | |
154 _charset=no | |
155 ;; | |
156 -oll) | |
157 _oll=yes | |
158 ;; | |
159 -nooll) | |
160 _oll=no | |
161 ;; | |
162 -svn) | |
163 _svn=yes | |
164 ;; | |
165 -nosvn) | |
166 _svn=no | |
167 ;; | |
168 -head) | |
169 _head=yes | |
170 ;; | |
171 -nohead) | |
172 _head=no | |
173 ;; | |
174 -color) | |
175 _color=yes | |
176 ;; | |
177 -nocolor) | |
178 _color=no | |
179 ;; | |
180 -spaces) | |
181 _spaces=yes | |
182 ;; | |
183 -nospaces) | |
184 _spaces=no | |
185 ;; | |
186 -extensions) | |
187 _extensions=yes | |
188 ;; | |
189 -noextensions) | |
190 _extensions=no | |
191 ;; | |
192 -crlf) | |
193 _crlf=yes | |
194 ;; | |
195 -nocrlf) | |
196 _crlf=no | |
197 ;; | |
198 -tabs) | |
199 _tabs=yes | |
200 ;; | |
201 -notabs) | |
202 _tabs=no | |
203 ;; | |
204 -trailws) | |
205 _trailws=yes | |
206 ;; | |
207 -notrailws) | |
208 _trailws=no | |
209 ;; | |
210 -rcsid) | |
211 _rcsid=yes | |
212 ;; | |
213 -norcsid) | |
214 _rcsid=no | |
215 ;; | |
216 -all) | 150 -all) |
217 enable_all_tests | 151 enable_all_tests |
218 ;; | 152 ;; |
219 -noall) | 153 -noall) |
220 disable_all_tests | 154 disable_all_tests |
221 ;; | 155 ;; |
222 -none) | 156 -none) |
223 disable_all_tests | 157 disable_all_tests |
224 ;; | 158 ;; |
225 -showcont) | |
226 _showcont=yes | |
227 ;; | |
228 -noshowcont) | |
229 _showcont=no | |
230 ;; | |
231 -gnu) | |
232 _gnu=yes | |
233 ;; | |
234 -nognu) | |
235 _gnu=no | |
236 ;; | |
237 -res) | |
238 _res=yes | |
239 ;; | |
240 -nores) | |
241 _res=no | |
242 ;; | |
243 -*) | 159 -*) |
160 var=`echo X$i | sed 's/^X-//'` | |
161 val=yes | |
162 case "$var" in | |
163 no*) | |
164 var=`echo "$var" | cut -c 3-` | |
165 val=no | |
166 ;; | |
167 esac | |
168 case "$allflags" in | |
169 *\ $var\ *) | |
170 eval _$var=$val | |
171 ;; | |
172 *) | |
244 echo "unknown option: $i" >&2 | 173 echo "unknown option: $i" >&2 |
245 exit 0 | 174 exit 0 |
175 ;; | |
176 esac | |
246 ;; | 177 ;; |
247 *) | 178 *) |
248 _files="$_files $i" | 179 _files="$_files $i" |
249 ;; | 180 ;; |
250 esac | 181 esac |