bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GNU sed Bug (Single Quotes in Comments Cause Errors)


From: Bob Proulx
Subject: Re: GNU sed Bug (Single Quotes in Comments Cause Errors)
Date: Mon, 5 Sep 2005 12:23:46 -0600
User-agent: Mutt/1.5.9i

Jonathan Levi MD wrote:
> Paolo Bonzini wrote:
> > This is because the shell sees the single quote as a terminator of 
> > the other single quote.
> 
> Paolo, are you sure the problem is with the shell?

Even if he is not, I know I am sure.  The problem is with the single
quote you are using.

> echo some text | sed '${
>         p       # works if you'll delete the single quote!
> }'

The shell groups strings according to quoting.  From the first single
quote to the second is one string.  Then from the second to the
second.  And so forth.  But you have unmatched quotes there.  Try echo
to see what sed sees.

  echo '${
          p       # works if you'll delete the single quote!

You will see:

  ${
            p       # works if youll delete the single quote!

That does not part for sed.  That is why you are seeing an error message.

> Here's a slightly longer script with a commented ' in the midst of a
> sed command and a shell command, and also with line numbers; note
> that not only does sed fail, but it complains (by name) about the
> lack of a (nonexistent) file:

I think you are just getting really confused by how the shell is
tokenizing strings with quotes.  But really it is all making sense if
you look them over the same way the shell does.

Bob




reply via email to

[Prev in Thread] Current Thread [Next in Thread]