Subject: Re: fix for pd-ksh globbing
To: None <tech-userlevel@netbsd.org>
From: Greg A. Woods <woods@weird.com>
List: tech-userlevel
Date: 01/26/2002 16:38:27
[ On Saturday, January 26, 2002 at 16:08:43 (-0500), kpneal@pobox.com wrote: ]
> Subject: Re: fix for pd-ksh globbing
>
> On Fri, Jan 25, 2002 at 03:36:15PM -0500, Greg A. Woods wrote:
> > too. ("A single-quote cannot occur within single-quotes. A backslash
> > cannot be used to escape a single-quote in a single-quoted string.")
>
> Can a single-quote be escaped by putting it inside double-quotes
> (inside the single-quotes)?
Yes, but not within the single-quotes, at least not in POSIX/SUSv2. A
double-quote character within a single-quoted string has no special
meaning:
$ echo 'foo"bar'
foo"bar
$
You have to end the single-quoted string, double-quote the single quote,
and then start the single-quoted string. The whole thing will still be
treated as one field. This does work for both /bin/sh and /bin/ksh on
NetBSD.
> It seems to work on HP-UX ksh I think.
That's strange. What KSH version is it? It should not. It does not
work in KSH M-11/16/88i, as shipped with SunOS-5.8 (and earlier).
$ echo 'foo"'"bar'
>>> <INTR>
$ echo 'foo'"'"'bar'
foo'bar
$
> Make's :Q modifier gets this
> wrong.
Hmmmm..... so it does.... I see I have a related bug in some of my
own code too! ;-)
--
Greg A. Woods
+1 416 218-0098; <gwoods@acm.org>; <g.a.woods@ieee.org>; <woods@robohack.ca>
Planix, Inc. <woods@planix.com>; VE3TCP; Secrets of the Weird <woods@weird.com>