On Sunday 19 August 2007 04:00:45 »Q« wrote: > It works as it is, but I'm interested in learning about any newbie traps > into which I might be falling or about any better practices I should > use. This is my first attempt at printing a usage message or parsing > arguments. > > The script is at <http://remarqs.net/misc/mids2urls.sh.txt>. Feel free > to reply to me off-list (or just to flame me) if you think this kind of > non-Gentoo-specific stuff has no place here.
It's hardly the best place to ask this kind of question but anyway.. :p The most noticeable thing which is wrong with this script is the quoting inside the brackets [ ]. Since you use bash you should just use [[ ]] instead (which makes most of the quoting in them unneeded..). Also things like [[ $foo == "" ]] should rather be [[ -n $foo ]] but that's a minor. Finally the number of calls to grep, sed and tr clearly shows that you could improve your knowledge about sed.. ;) http://wooledge.org/mywiki/BashFAQ#head-b1c292ce2f4fdfa6a7b5389da1892d65b6f37cda -- Bo Andresen
signature.asc
Description: This is a digitally signed message part.