On 10/14/05, David M. Cook <[EMAIL PROTECTED]> wrote:
> Is there a neater idiom for this:
>
> #!/bin/sh
>
> if test -f $1
> then
>   if test ! -d $1
>   then
>     echo "$1 exists and is not a directory"
>     exit 1
>   fi
> else
>   mkdir -p $1
> fi
> #########
>
> If a file exists and is not a directory, bail out, otherwise create the
> directory.
>
> Dave

With few exceptions, I do my shell scripting in Python so can I put
these things in methods that I reuse:

    self.ensureDir("/foo/bar")

Come on, Dave, I know you love Python!  :-)


-Chuck

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to