[OS X TeX] verbatim problems

Norman Gray norman at astro.gla.ac.uk
Sat Jul 8 16:45:43 CEST 2006


Arthur,

On 2006 Jul 7 , at 18.44, Arthur Snoke wrote:

> first one worked with todos 'perl -pe "s/$/\r/"'
>
>> alias todos="perl -pe 's/$/\r/'"

> What is the rule of ' vs. "?

The difference is that '...' is completely verbatim, whereas "..."  
expands variables, and allows backslash quotation.  Thus "x$x\'"  
expands to a string which includes the expansion of variable $x and a  
single quote, whereas 'x$x\'' expands to a string x$x\ plus an  
unbalanced quote mark.  The only function of "...", really, is to  
make it easy to include spaces in a string.

But the alias I quoted doesn't work straightforwardly according to  
that rule, as bash won't expand something that doesn't look like a  
variable reference -- the '$' isn't followed by an alphanumeric  
character -- and \r isn't a bash escape.  The bash manpage says "The  
rules concerning the definition and use of aliases are somewhat  
confusing", which is putting it mildly.  csh's rules are probably  
worse, partly because they'd have to deal with parameter references  
(which (ba)sh handles with a separate, better, mechanism of shell  
functions, which sidesteps quoting hell).

As Peter Dyballa points out, there's extra complication in that there  
are two phases of expansion, namely when the alias is defined and  
when it's used.

Most reliable, therefore, is to define the csh alias via

% alias todos 'perl -pe '\''s/$/\r/'\'

and this appears to work when I try it.

All the best,

Norman


-- 
------------------------------------------------------------------------ 
----
Norman Gray  /  http://nxg.me.uk
eurovotech.org  /  University of Leicester, UK



------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list