Subject: Re: Re: [shell-discuss] shellstyle
--------

> David Korn wrote:
> > 
> > Subject: Re: [shell-discuss] shellstyle
> > --------
> > 
> 
> > Always use '{'+'}' when using variable names longer than one character.
> >         I would allow the {} to be omitted for simple named variables
> >         that are followed by a blank, /, ;, or $.
> 
> Mhhh... I am not sure whether it's a good idea to add too many
> exceptions...
I think that $dir/$file is easier to read than ${dir}/${file} and
certainly harder to write.
> 
> > Always put variables into quotes when handling filenames or user input.
> >         There is no need for quotes with assignment, redirection words or
> >         inside [[...]].  They can also be omitted if IFS='' and set -o 
> > noglob.
The quoting is not needed for
        assignments
        redirections
        inside [[....]]
        inside ((...))
        case ...
since in all these cases neither word splitting or file name generation
is performed.   However, not that for [[ name == pattern ]] quoting
pattern causes it to be treated as a literal string.
> 
> I've added a note for this:
> -- snip --
> <note><para>
> As alternative a script may set <literal>IFS='' ; set -o
> noglob</literal> to turn off the
> interpretation of any field seperators and the pattern globbing.
> </para></note>
> -- snip --
> 
> ----
> 
> Bye,
> Roland
> 

David Korn
dgk at research.att.com

Reply via email to