[I sent this earlier with the intent to send it to the list, but the
reply-to was on Natanael's personal address. So, better late than never,
even though someone else has posted similar recommendations already by
now...]
You could rewrite like this (including test input):
echo "#define BOOT_TRAMPOLINE 0x7c000" |
sed -nr 's/^#define[[:space:]]+BOOT_TRAMPOLINE[[:space:]]+//p'
Or if you prefer to keep the commas instead of the slashes:
echo "#define BOOT_TRAMPOLINE 0x7c000" |
sed -nr 's,^#define[[:space:]]+BOOT_TRAMPOLINE[[:space:]]+,,p'
I think it is rather odd to use "{1,}" as a quantifier instead of "+"
and a comma as a separator instead of a slash in a case where you have
other commas which you need to escape. I also think the "-r" mode is
often a good option (I use it regularly) because it saves you from
having to escape meta characters. The regexes just become more readable
like that.
As for the "{1,}" quantifier, it does work in both normal and extended
("-r") regex mode, just not in connection with using comma as a
separator instead of slash. So that may give developers a hint where to
look for a possible bug:
echo "#define BOOT_TRAMPOLINE 0x7c000" |
sed -nr 's/^#define[[:space:]]{1,}BOOT_TRAMPOLINE[[:space:]]{1,}//p'
Or if you want to avoid "-r" mode, this also works:
echo "#define BOOT_TRAMPOLINE 0x7c000" |
sed -n 's/^\#define[[:space:]]\{1,\}BOOT_TRAMPOLINE[[:space:]]\{1,\}//p'
As for extending or fixing BB sed, I guess an active developer will
answer that later. I am just another user.
--
Alexander Kriegisch (kriegaex)
http://freetz.org
> When building xen it fails with a sed expression. Building with GNU sed works.
>
> $ 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 \{\}
>
> I have not investigated if the sed line could be rewritten in a
> standards compliant way or if its a bug in busybox sed.
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox