In article <
barmar-30D67B....@news.eternal-september.org>,
Barry Margolin <
bar...@alum.mit.edu> wrote:
> In article <
nospam-3D7EBD....@news.chingola.ch>,
> Paul Sture <
nos...@sture.ch> wrote:
>
> > That reminds me of something I came across in VMS many years ago. One
> > way to insert double quotes into a string using that CLI was to double
> > them up e.g.
> >
> > string = "some text ""quoted substring"" more text"
> >
> > Yet with one particular utility which talked to a foreign system (via
> > FTP or NFS IIRC), you needed to triple those quotes. We never worked
> > out why, but were happy that it worked.
>
> Things do get tricky when you need to get a quoted substring into the
> arguments of a program. On Unix, the challenge often arises when you're
> doing:
>
> ssh hostname <command>
>
> If the command you're trying to run contains quoted strings and
> variables, figuring out all the quoting and escaping can be difficult.
> I've nearly driven myself crazy trying to run awk commands like this,
> since you need to ensure that $ is NOT expanded either locally or in the
> remote shell, because it has to get into awk's literal argument.
I have run into that one too. You can easily start tearing your hair
out.
> I used to use Multics, which also use quote doubling. Its equivalent to
> Unix's "if" and "for" commands required putting the body as a single
> quoted argument, so if you had nested conditionals and loops you could
> easily end up with a sequence of 8 or 16 quotes (actually, this was only
> necessary for interactive commands -- it had a separate mechanism for
> running scripts that added its own directives for flow control).
That reminds me. I had a devil of a job trying to escape the apostrophe
in "iWork '09" using Applescript. I finally found a solution, but when
I came across a comment that the behaviour might change in a future
version of OS X, I thought "Nuts, I'm not going through that again", and
wrote a temporary file to execute instead. I didn't like that solution
but it was going to be maintainable...
--
Paul Sture