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

Simon Horman horms at verge.net.au
Mon Jul 12 22:02:25 EDT 2010


On Mon, Jul 12, 2010 at 12:13:45PM +0200, Lars Ellenberg wrote:
> 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".

That I didn't know :-)

> 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.

I vote for your original, more portable option.





More information about the Pacemaker mailing list