groff
[Top][All Lists]
Advanced

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

Re: [Groff] Re: What's missing for Unicode support of groff?


From: Keith Marshall
Subject: Re: [Groff] Re: What's missing for Unicode support of groff?
Date: Sun, 11 Dec 2005 23:17:22 +0000

On Sunday 11 December 2005 6:46 pm, Zvezdan Petkovic wrote:
[regarding the sed expression used to identify the installed texinfo version]
> Thus your expression should have been (only \+ has been replaced
> with \{1,\} below):
>
>         's/^.* \([^ ]\{1,\}\)$/\1/;1q'
>
> In fact, I'd rather use
>
>         sed -e 's/^.* \([^ ]\{1,\}\)$/\1/' -e '1q'
>
> it's more readable.

Not only is the latter expression more readable, it is also more strictly 
conformant with official sed documentation, and I too would prefer it that 
way.  Indeed, although it was I who suggested the

    's/^.* \([^ ]\+\)$/\1/;1q'

format, I had only very recently become aware of the possibility to use 
semicolons as sed command separators in this way;  we did note at the time 
that it was not formally documented in GNU sed documentation, although it 
does appear in several examples, without explanation.

I've subsequently checked the manpage for sed on a Solaris box at work;  this 
expressly permits the use of a semicolon as an alternative to the comma, 
between the two components of a range specification, but demands the use of 
newlines to separate commands within a single script argument.  (In spite of 
this, the format using the semicolon does work as intended, on this very 
Solaris box).

I'd not previously been aware of the restriction on the use of the `+' to 
mean `one or more repeats of the preceding RE, (thanks for the heads up, 
Zvezdan), although where I've previously seen it documented, it was never 
indicated that it should be written as `\+', but rather as simply `+'.  
However, I don't believe I've ever used a sed implementation where it has 
worked as intended, without the escape.

On the whole, for maximum portability, I'd be inclined to adopt the syntax 
suggested by Zvezdan, i.e.

    sed -e 's/^.* \([^ ]\{1,\}\)$/\1/' -e '1q'

Regards,
Keith.




reply via email to

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