From: Harald Hanche-Olsen on
This whole thing reminds me of one of the questions most frequently
asked, and most frequently answered wrongly, on comp.unix.shell: How to
remove a file whose name starts with a hyphen (say, -i). The most common
wrong answer has to be: rm \-i or alternatives like rm '-i' or even
rm -* while a few semi-enlightened souls go for rm -- -i which will
work in some shells, but isn't portable. The portable answer is, of
course, rm ./-i

There is similar confusion with respect to URL encoding versus entities
in HTML attributes.
--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
From: Teemu Likonen on
* 2010-02-07 18:43 (-0500), Harald Hanche-Olsen wrote:

> [...] semi-enlightened souls go for rm -- -i which will work in some
> shells, but isn't portable. The portable answer is, of course, rm ./-i

And I think that it doesn't depend on the shell but the "rm" command
itself. It's the command's job to interpret "--" as the end of options.
From: Harald Hanche-Olsen on
+ Teemu Likonen <tlikonen(a)iki.fi>:

> * 2010-02-07 18:43 (-0500), Harald Hanche-Olsen wrote:
>
>> [...] semi-enlightened souls go for rm -- -i which will work in some
>> shells, but isn't portable. The portable answer is, of course, rm ./-i
>
> And I think that it doesn't depend on the shell but the "rm" command
> itself. It's the command's job to interpret "--" as the end of options.

Yeah, of course. I don't know what I was thinking. Especially in a post
where I was complaining about /other/ people's sloppiness.

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
when there is no ground whatsoever for supposing it is true.
-- Bertrand Russell
From: Ron Garret on
In article
<364c0f3d-a789-47b2-9f56-34b68eddc09f(a)u9g2000yqb.googlegroups.com>,
"webmasterATflymagnetic.com" <webmaster(a)flymagnetic.com> wrote:

> On Feb 6, 6:34 pm, Morgan <bauer.mor...(a)gmail.com> wrote:
> > On Feb 6, 1:22 pm, "webmasterATflymagnetic.com"
> >
> >
> >
> > <webmas...(a)flymagnetic.com> wrote:
> > > Hi,
> >
> > > anyone know how to escape double quotes in a format directive? I'm
> > > trying to do the equivalent of the Unix shell command:
> >
> > > echo "<a href=\"$1\">$2</a>"
> >
> > > but with format:
> >
> > > (format t "<a href=~"~A~">~A</a>" text1 text2)
> >
> > > But CLISP says 'EVAL: variable ~A~ has no value.'
> >
> > > OK, so I guessed at the ~" being an escape of the double quote, mainly
> > > on the fact that ~~ is an escape of the tilde. I guessed wrong. What's
> > > the correct answer?
> >
> > > Phil
> >
> > Hello Phil,
> >
> > Use '\'.
> >
> > (format t "string with a \" in it")
> >
> > (format t "<a href=\"~A\">~A</a>" text1 text2)
> >
> > hth
> > --Morgan
>
> he he, it works. Thanks!

If you're using a Lisp that supports unicode you can also do something
like this:

(defun make-string-reader (c1 c2)
(set-macro-character
c1
(lambda (stream c)
(declare (ignore c))
(with-output-to-string (s)
(loop for c = (read-char stream)
with cnt = 1
if (eql c c1) do (incf cnt)
else if (eql c c2) do (decf cnt)
until (and (eql c c2) (eql cnt 0))
do (princ c s))
s))
t))

(make-string-reader #\« #\»)

? (format nil «<a href="~A">~A</a>» «Link» «Text»)
"<a href=\"Link\">Text</a>"

rg