* Re: What's wrong with this code??
[not found] ` <87eiha5ipf.fsf@fh-trier.de>
@ 2010-05-18 7:09 ` Santanu
2010-05-18 14:37 ` Frédéric Perrin
0 siblings, 1 reply; 5+ messages in thread
From: Santanu @ 2010-05-18 7:09 UTC (permalink / raw)
To: help-gnu-emacs
On May 18, 2:20 am, Andreas Politz <poli...@fh-trier.de> wrote:
> Santanu <thisissant...@gmail.com> writes:
> > Hello Everybody,
>
> > Can you tell me what is wrong with this code:
> > -------------------
> > (setq
> > go-packages-installed
> > (split-string
> > (shell-command-to-string
> > "cd $GOROOT/src/pkg && find . -iname *.go | sed -e 's|^\./||g; s|/
> > [^/]*\.go||g' | sort | uniq"\
> > )))
>
> You have to escape the backslash characters, because of string
> expansion.
Spot on. Thank you very much.
BTW, can you also explain a bit what it means when I don't put the
double backslash character, and instead use a single backslash?
I ask this because my original code (the incorrect one above) did
produce some correct results.
Regards,
Santanu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What's wrong with this code??
2010-05-18 7:09 ` What's wrong with this code?? Santanu
@ 2010-05-18 14:37 ` Frédéric Perrin
2010-05-18 17:34 ` Santanu
0 siblings, 1 reply; 5+ messages in thread
From: Frédéric Perrin @ 2010-05-18 14:37 UTC (permalink / raw)
To: help-gnu-emacs
Santanu <thisissantanu@gmail.com> writes:
> On May 18, 2:20 am, Andreas Politz <poli...@fh-trier.de> wrote:
>> Santanu <thisissant...@gmail.com> writes:
>> > Can you tell me what is wrong with this code:
>> > -------------------
>> > (setq
>> > go-packages-installed
>> > (split-string
>> > (shell-command-to-string
>> > "cd $GOROOT/src/pkg && find . -iname *.go | sed -e 's|^\./||g; s|/
>> > [^/]*\.go||g' | sort | uniq"\
>> > )))
>>
>> You have to escape the backslash characters, because of string
>> expansion.
>
> BTW, can you also explain a bit what it means when I don't put the
> double backslash character, and instead use a single backslash? I
> ask this because my original code (the incorrect one above) did
> produce some correct results.
The first expression in the sed was « s|^./||g; » (which didn't hurt,
because it seems that you don't have directories whoose name contains
only a single letter), and the second wes « s|/[^/]*.go||g », with the
LHS matching strings such as « /svgo ».
--
Fred
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What's wrong with this code??
2010-05-18 14:37 ` Frédéric Perrin
@ 2010-05-18 17:34 ` Santanu
2010-05-18 21:04 ` Stefan Monnier
0 siblings, 1 reply; 5+ messages in thread
From: Santanu @ 2010-05-18 17:34 UTC (permalink / raw)
To: help-gnu-emacs
On May 18, 7:37 pm, Frédéric Perrin <fred...@SPAM.resel.fr> wrote:
> Santanu <thisissant...@gmail.com> writes:
> > On May 18, 2:20 am, Andreas Politz <poli...@fh-trier.de> wrote:
> >> Santanu <thisissant...@gmail.com> writes:
> >> > Can you tell me what is wrong with this code:
> >> > -------------------
> >> > (setq
> >> > go-packages-installed
> >> > (split-string
> >> > (shell-command-to-string
> >> > "cd $GOROOT/src/pkg && find . -iname *.go | sed -e 's|^\./||g; s|/
> >> > [^/]*\.go||g' | sort | uniq"\
> >> > )))
>
> >> You have to escape the backslash characters, because of string
> >> expansion.
>
> > BTW, can you also explain a bit what it means when I don't put the
> > double backslash character, and instead use a single backslash? I
> > ask this because my original code (the incorrect one above) did
> > produce some correct results.
>
> The first expression in the sed was « s|^./||g; » (which didn't hurt,
> because it seems that you don't have directories whoose name contains
> only a single letter), and the second wes « s|/[^/]*.go||g », with the
> LHS matching strings such as « /svgo ».
Ah... I see. Now I understand. So, basically, just a singe '\'
character in an elisp
regexp string acts as if it wasn't even there in the first place.
Thank you for the explanation.
Regards,
Santanu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What's wrong with this code??
2010-05-18 17:34 ` Santanu
@ 2010-05-18 21:04 ` Stefan Monnier
2010-05-19 8:57 ` Santanu
0 siblings, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2010-05-18 21:04 UTC (permalink / raw)
To: help-gnu-emacs
> Ah... I see. Now I understand. So, basically, just a single '\'
> character in an elisp regexp string acts as if it wasn't even there in
> the first place.
Yes, except when it's a valid escape sequence, i.e. when the backslash
is followed by r, t, ^, C, M, 0-9, x, o, d, e, a, b, v, LF, n, ", s, u,
U, or f (and maybe a few more ;-).
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: What's wrong with this code??
2010-05-18 21:04 ` Stefan Monnier
@ 2010-05-19 8:57 ` Santanu
0 siblings, 0 replies; 5+ messages in thread
From: Santanu @ 2010-05-19 8:57 UTC (permalink / raw)
To: help-gnu-emacs
On May 19, 2:04 am, Stefan Monnier <monn...@iro.umontreal.ca> wrote:
> > Ah... I see. Now I understand. So, basically, just a single '\'
> > character in an elisp regexp string acts as if it wasn't even there in
> > the first place.
>
> Yes, except when it's a valid escape sequence, i.e. when the backslash
> is followed by r, t, ^, C, M, 0-9, x, o, d, e, a, b, v, LF, n, ", s, u,
> U, or f (and maybe a few more ;-).
Thanks. I will have to keep this in mind too.
Things now got a bit more complex :-)
Regards,
Santanu
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-19 8:57 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <65c33ee7-8443-4cec-8227-9005bf4fe494@v29g2000prb.googlegroups.com>
[not found] ` <87eiha5ipf.fsf@fh-trier.de>
2010-05-18 7:09 ` What's wrong with this code?? Santanu
2010-05-18 14:37 ` Frédéric Perrin
2010-05-18 17:34 ` Santanu
2010-05-18 21:04 ` Stefan Monnier
2010-05-19 8:57 ` Santanu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).