SOURCES: service_generator.sh - use == instead of = for tests

Jakub Bogusz qboosh at pld-linux.org
Wed Jun 21 12:45:01 CEST 2006


On Wed, Jun 21, 2006 at 12:25:43PM +0200, Radoslaw Zielinski wrote:
> Jakub Bogusz <qboosh at pld-linux.org> [21-06-2006 11:32]:
> > On Sun, Jun 11, 2006 at 07:02:34PM +0200, radek wrote:
> >> Author: radek                        Date: Sun Jun 11 17:02:34 2006 GMT
> >> Module: SOURCES                       Tag: HEAD
> >> ---- Log message:
> >> - use == instead of = for tests
> 
> > Why? "=" is standard test operator.
> [...]
> >> -if [ $action = stop ]; then
> >> +if [ "$action" == "stop" ]; then
> 
> The commit message should be different, I wanted to fix this:
> 
>   $ cvs up -r1.5 service_generator.sh
>   P service_generator.sh
> 
>   $ sh service_generator.sh foo >/dev/null
>   service_generator.sh[16]: [: stop: unexpected operator/operand

It was caused by missing double quotes.

> I wasn't sure if "=" is preferred to "=="; as I find the former
> ambigous, I changed it too.  POSIX indeed defines only "=" while
> describing "test", but section 1.7.2 lists "==" ("Concepts Derived
> from the ISO C Standard"), so I guess it can also be considered
> conformant.

At least /usr/bin/test (coreutils-5.2.1-5) doesn't support "==".
ksh's builtin test does.


-- 
Jakub Bogusz    http://qboosh.cs.net.pl/


More information about the pld-devel-en mailing list