just another one of my rumblings

Paul Fox pgf at brightstareng.com
Thu Apr 24 20:30:48 UTC 2008


 > On Thu, 2008-04-24 at 21:09 +0200, Cristian Ionescu-Idbohrn wrote:
 > >   [ -n "$bindir" ] || bindir=$(dirname $(pwd))
 > 
 > Even better is to avoid dirname altogether.  It's actually not necessary
 > at all in a POSIX shell; neither is basename.
 > 
 > The above can be rewritten much more efficiently as:
 > 
 >  pwd=$(pwd)
 >  : ${tsdir:=$pwd}
 >  : ${bindir:=${pwd%/*}}
 > 
 > Just sayin'... :-)
 > 
 > I'm assuming this script is declared #!/bin/bash at the top, due to all
 > the bashisms it uses?

and if so, one could use $PWD.

 : ${tsdir:=$PWD}
 : ${bindir:=${PWD%/*}}

paul
=---------------------
 paul fox, pgf at brightstareng.com



More information about the busybox mailing list