bash and strings
    Girish Venkatachalam 
    girishvenkatachalam at gmail.com
       
    Thu Nov 15 22:34:35 PST 2007
    
    
  
On 21:18:47 Nov 15, Garrett Cooper wrote:
> A better way would be to quote the string variables, i.e.:
> 
> DIR=`/usr/bin/dirname "$path"`
> FILE=`/usr/bin/basename "$path"`
> /bin/mkdir -p "$DIR"
> touch "$FILE"
> 
> Otherwise dirname and basename will choke on non-escaped characters 
> (i.e. spaces), mkdir/touch will make funky directories / files, 
> respectively.
> 
> Just watch out for '$' chars in $path...
> 
> Welcome to the wonderful world of [in]secure shell scripting :).
> 
Thanks buddy. :)
I missed out something obvious.
Ever willing to learn.
regards,
Girish
    
    
More information about the freebsd-questions
mailing list