just another one of my rumblings

Paul Smith paul at mad-scientist.us
Thu Apr 24 19:26:19 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?




More information about the busybox mailing list