Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Rsync exclusion question



Josh Glover wrote:
I think the Best Practise to always use non-interpolating quotes unless you know you need interpolation is the way to go. That way,
you don't need to understand the interpolation rules of your
programming language all the way down to the metal.

I don't know how you can include not understanding the language you are using in a Best Practice ;-)

Seeing as the interpolation and wildcard expansion rules affect both the
security and correctness of your scripts, spending a few minutes to
understand these simple rules will not only save you time debugging (for
certain) but also possibly prevent minor catastrophes. (Both over- and
under- quoting cause problems.)

I don't understand why the problem was allegedly fixed by changing between " and ' quotes; perhaps we haven't heard the full story.

From the Bash manpage
       Enclosing  characters  in  double quotes preserves the literal value of
       all characters within the quotes, with the exception of $, ‘,  \,  and,
       when  history  expansion  is enabled, !.  The characters $ and ‘ retain
       their special meaning within double quotes.  The backslash retains  its
       special  meaning only when followed by one of the following characters:
       $, ‘, ", \, or <newline>.  A double quote may be quoted  within  double
       quotes by preceding it with a backslash.  If enabled, history expansion
       will be performed unless an !  appearing in double  quotes  is  escaped
       using a backslash.  The backslash preceding the !  is not removed.

       The  special  parameters  *  and  @ have special meaning when in double
       quotes (see PARAMETERS below).


From the BSD sh manpage
   Single Quotes
     Enclosing characters in single quotes preserves the literal meaning of
     all the characters (except single quotes, making it impossible to put
     single-quotes in a single-quoted string).

   Double Quotes
     Enclosing characters within double quotes preserves the literal meaning
     of all characters except dollarsign ($), backquote (‘), and backslash
     (\).  The backslash inside double quotes is historically weird, and
     serves to quote only the following characters:
           $ ‘ " \ <newline>.
     Otherwise it remains literal.



Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links