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

Re: Several reasons why debian should not use bash for /bin/sh

-- On Jul 31, 12:21am, Roberto Lumbreras wrote:
> Subject: Re: Several reasons why debian should not use bash for /bin/sh
> I use a lot bash substitutions like this...
> bash-2.01$ blah="psee:jjkkuu"; echo ${blah/*:/}
> jjkkuu
> bash-2.01$
> I don't know how to do that in sh without awk, cut or sed. Ideas? ;-)
> Roberto Lumbreras
-- End of excerpt from Roberto Lumbreras --

  This one is easy
echo $blah | IFS=: read a b ; echo $b

  This only works in posix shells.  In traditional bourne shell, the
read is executed in a subshell which goes away after the read finishes.
To make this work in traditional sh, one must do something like
echo $blah | { IFS=: read a b ; echo $b ; }

  Come on -- give me something harder ;)

  It's easy, actually, to come up with things that don't work in
traditional /bin/sh that are very useful.  I guess this is why people
added the extra functionality.  I imagine that it's harder to come up
with bashisms that are useful for which there are no posix alternatives.

 Chris Ulrich        cdulrich@ucdavis.edu        530 754 4355

To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: