[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax Question...
From: |
Linda Walsh |
Subject: |
Re: Syntax Question... |
Date: |
Tue, 16 Aug 2011 03:51:01 -0700 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.24) Gecko/20100228 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666 |
` Dennis Williamson wrote:
Also, it's usually not necessary to maintain an index variable
and use shift in a while loop. Use "for arg; do" which uses an implied
$@.
I tried to implement your suggestion and quickly ran into the reasons
why I did what I did.
Using the 'for x;do' format, 1 argument can't 'swallow up the next'.
This has to happen in the case of a single letter option that if
followed by it's argument -- so yeah, could set a flag and catch it
through on a another loop, but easier just to do another 'shift' and
pull the next arg.
2nd, the counter was for the non-intercepted cmdline values. The
option parser only removes options it knows about and returns the rest
to the caller -- I used the counter to index that array, w/slightly
less typing & complexity than in an earlier design I had 2 counters
- one for the input and one for the output as they would differ
as soon as some params weren't copied to the output array -- but
then went with the paradigm you saw, as it allowed me have flags that
took values, grab them, immediately, rather than setting a flag
for a next loop.
I could have used:
array_name[${array_name[*]}]="new value"...
instead of a counter, but, the counter was already there from the previous
version and less untidy looking.
- Re: Syntax Question..., (continued)
- Re: Syntax Question..., Ken Irving, 2011/08/16
- Re: Syntax Question..., Dennis Williamson, 2011/08/16
- Re: Syntax Question..., Linda Walsh, 2011/08/16
- Re: Syntax Question..., Ken Irving, 2011/08/16
- Re: Syntax Question..., Greg Wooledge, 2011/08/17
- Re: Syntax Question..., Linda Walsh, 2011/08/19
- Re: Syntax Question...,
Linda Walsh <=
- Re: Syntax Question..., Pierre Gaston, 2011/08/15
- Re: Syntax Question..., Linda Walsh, 2011/08/18
- Re: Syntax Question..., Pierre Gaston, 2011/08/18
- Re: Syntax Question..., Linda Walsh, 2011/08/18