On 2013-06-18 22:08, Tim Connors wrote:
[...]
> > instances, I'd use {0..32} instead of `seq 0 32`.
>
> Never heard of that before. Definitely not POSIX (gut feeling here - no
> POSIX reference manual handy, but it doesn't work in dash). Never seen
> seq not work (assumed it was posix - I even saw it work on HP-UX of all
> things. Heck, it probably even works on SCO).
You're right, {0..32} isn't POSIX; I did further research further down
the email, most notably the stuff from Greybot (which, for reference,
lurks in Freenode/#bash).
>
> > I also advice using
Oops. *advise
> > $(cidr2mask "$cidr") rather than `cidr2mask "$cidr"`; The $() notation
> > is newer and more predictable, especially with regard to quoting.
>
> Yeah, trying to get out of the habit (` is still prettier for small
> snippets), however I thought $(prog) is not POSIX (I'm straying well away
> from posix in this program anyway), whereas ` is. (how do you google for
> "`" and "$(" ?)
Both POSIX (at least for newer POSIX versions). For reference:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_03
(Also worth noting though that, e.g. Solaris sh doesn't adhere to
current POSIX, and implements `` but not $().)
[...]
> Here's some useful network calculations someone might find useful (after
> suitably debugging and commenting), that should never be deployed in
> production because I do silly things like work out what $0 is (so can be
> symlinked to netcalc, bcasecacl, cidr2mask, mask2cidr) without any sanity
> checking:
>
> http://rather.puzzling.org/~tconnors/code/cidr2mask
Pfft, that's easily fixed:
case "${0##*/}" in
mask2cidr|cidr2mask|netcalc|bcastcalc) "${0##*/}";;
*) echo 'ERROR!' >&2; exit 1;;
esac
... And that's all POSIX, not that it matters given you're invoking as
/bin/bash.
[...]
>
> Urk. Big array not generated by a simple loop.
I agree, but I couldn't come up with a more elegant solution in the time
I allocated myself. Will take a look at your script for ideas.
--
Regards,
Matthew Cengia
signature.asc
Description: Digital signature
_______________________________________________ luv-main mailing list [email protected] http://lists.luv.asn.au/listinfo/luv-main
