Re: Tests [ 0 -eq $UID ] don't work as in bash

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

 



On Wed, 2016-09-07 at 16:44 +0200, Andrey Voropaev wrote:
> if [ 0 -eq $UID ]

The variable UID is not defined to be automatically set by the shell in
POSIX; having it set is a bash extension.  dash doesn't set it
automatically for you.

You'll have to set it yourself:

  UID=$(id -u)

Also you should quote variable references, in general:

  if [ 0 -eq "$UID" ]

Be sure that if your scripts rely on bash-isms you start them with
#!/bin/bash and if you don't want them to rely on bash-isms, you start
them with #!/bin/sh.
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux