sed issue

Natanael Copa natanael.copa at gmail.com
Fri Jan 13 13:47:01 UTC 2012


On Fri, Jan 13, 2012 at 12:16 PM, Cristian Ionescu-Idbohrn
<cristian.ionescu-idbohrn at axis.com> wrote:
> On Fri, 13 Jan 2012, Bernd Petrovitsch wrote:
>> On Fre, 2012-01-13 at 10:28 +0100, Natanael Copa wrote:
>> [...]
>> > When building xen it fails with a sed expression. Building with
>> > GNU sed works.
>
> What busybox version was that?

busybox v1.19.3

>> > $ busybox sed -n
>> > 's,^\#define[[:space:]]\{1\,\}BOOT_TRAMPOLINE[[:space:]]\{1\,\},,p'
>> > sed: bad regex '^\#define[[:space:]]\{1\,\}BOOT_TRAMPOLINE[[:space:]]\{1\,\}':
>> > Invalid content of \{\}
>>
>> The line looks over-quoted as it is in single quotes and IMHO the
>> following was actually intended (or do I just miss a quoting level):
>> 's,^#define[[:space:]]{1,}BOOT_TRAMPOLINE[[:space:]]{1,},,p'
>>
>> > I have not investigated if the sed line could be rewritten in a
>> > standards compliant way or if its a bug in busybox sed.
>>
>> "{1,}" is equivalent to "+", so
>> 's/^#define[[:space:]]+BOOT_TRAMPOLINE[[:space:]]+//p'

awk is more readable...

awk '$1 == "#define" && $2 == "BOOT_TRAMPOLINE" {print $3}'

> That's extended regex, so a '-r' is required.
>
>> should be equivalent (and since we have no path names, we can use "/").
>
> Or a more neutral delimiter, like '|'.  And I don't think you want to
> use character class '[:space:]'.  What you're should use is
> '[:blank:]'.  A more robust regex:
>
> $ busybox sed -rne \
> 's|^[[:blank:]]*#[[:blank:]]*define[[:blank:]]+BOOT_TRAMPOLINE[[:blank:]]+||p'

I think I'll got with as little intrusive patch as possible for xen upstream.

\+ works.

Thanks all for the feedback.

-- 
Natanael Copa


More information about the busybox mailing list