[Pacemaker] [PATCH 2 of 2] low: remove various bashisms

Lars Ellenberg lars.ellenberg at linbit.com
Mon Jul 12 06:13:45 EDT 2010


On Mon, Jul 12, 2010 at 10:01:08AM +0900, Simon Horman wrote:
> > # because its friday, I'll give you some irrelevant input,
> > # doing it all in one pipe.  feel free to ignore ;-)
> > 
> > eval $(
> > printf "Garbage ignored\nCPU Type: speedy\nCPU Speed: gonzales\nNumber Of Cores: you won't guess\nOther information: ignored\n"  |
> > sed -n -e "
> > 	s/^CPU Type: /cpu_type=/
> > 	s/^CPU Speed: /cpu_speed=/
> > 	s/^Number Of.*: /cpu_cores=/
> > 	t shell_escape_and_print
> > 	b
> > 	: shell_escape_and_print
> > 	s/'/'\\\\''/g
> > 	s/=/='/
> > 	s/\$/'/
> > 	p
> > 	"
> > )
> > echo "$cpu_type"
> > echo "$cpu_speed"
> > echo "$cpu_cores"
> 
> Can it be simplified slightly like this?

- t shell_escape_and_print
- b
- : shell_escape_and_print
+ T

Where t, b, :, are all in "original sed",
and T is a "GNU sed specific addition".

Well, yes, sure it can.
But this all started in the name of "portability" (on a shell level).

Wether or not it is sensible to argue about shell level portability,
or sed script level portability, or the availability of GNU tools
well... leave that to some other day.

	Lars




More information about the Pacemaker mailing list