Mailinglist Archive: opensuse-packaging (130 mails)

< Previous Next >
Re: [opensuse-packaging] Proposal for a shell scripting policy
  • From: Guido Berhoerster <>
  • Date: Wed, 24 Mar 2010 17:32:43 +0100
  • Message-id: <20100324163243.GI7496@xxxxxxxxxxxxxxxxxx>
* Stephan Kulow <coolo@xxxxxxx> [2010-03-24 16:53]:
Am Mittwoch 24 März 2010 schrieb Michael Matz:

I trust that that one is more capable than our ash? :
% /bin/ash -c 'i=0; j=$((i+1))'
arith: syntax error: "i+1"

Make it $i - then both ash and dash can do it.

Note that $i and i lead to different behavior with arithmetic
expansion. $(( $i+1 )) happily yields 1 if i is set to a
non-integer while $(( i+1 )) results in a syntax error. The
latter is almost alway what you want since it catches potential

Assignments also do not work with $i, $(( $i=1 )) is an error
while $(( i=1 )) is valid and assigns i.

Except for legacy scripts it is probably a better idea to use
dash since it has many other issues fixed.
Guido Berhoerster
To unsubscribe, e-mail: opensuse-packaging+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse-packaging+help@xxxxxxxxxxxx

< Previous Next >