From: Paul Smith <paul@mad-scientist.net>
To: Andrey Voropaev <voropaev.andrey@gmail.com>, dash@vger.kernel.org
Subject: Re: Tests [ 0 -eq $UID ] don't work as in bash
Date: Wed, 07 Sep 2016 11:55:00 -0400 [thread overview]
Message-ID: <1473263700.7265.3.camel@mad-scientist.net> (raw)
In-Reply-To: <CAFOXTdceLsR_xBcs=B2QajQHW_UJyBKTr6R8fQvUNCxikYn77w@mail.gmail.com>
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.
next prev parent reply other threads:[~2016-09-07 16:23 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-07 14:44 Tests [ 0 -eq $UID ] don't work as in bash Andrey Voropaev
2016-09-07 15:55 ` Paul Smith [this message]
2016-09-07 20:02 ` Stephane Chazelas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1473263700.7265.3.camel@mad-scientist.net \
--to=paul@mad-scientist.net \
--cc=dash@vger.kernel.org \
--cc=voropaev.andrey@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).