dash issue after breezy->edgy upgrade

Adam Conrad adconrad at ubuntu.com
Thu Nov 2 11:17:22 UTC 2006

Jhair Tocancipa Triana wrote:
> The script runs fine with dash if I replace
>         if [ ${PPP_IPPARAM} == "vpn_tunnel" ];
> with
>         if [ ${PPP_IPPARAM} = "vpn_tunnel" ];
> Is this a dash bug? Or a bash bug? I've *heard* POSIX mandates =
> instead == in this case but I don't have a reference at hand for that.

"==" is a bashism, and one that confuses the heck out of every C
programmer who just immediately assumes it's correct (when it's
definitely not POSIX).

To think about why this isn't required in shell, realize that you can't
do assignment with $foo="foo" in shell, as it's foo="foo" ($foo always
implies a substitution), so unlike C, you don't need to semantic
difference between "assign to" and "equal to", and "=" pulls double duty
in POSIX shell.

The bottom line, of course, is that if you're writing /bin/sh scripts,
you should remember to test with a few shells.  If you can't be
bothered, just make it /bin/bash and be done with it. :)

... Adam

More information about the ubuntu-users mailing list