From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Baruch Siach <baruch@tkos.co.il>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: scripts
Date: Wed, 2 Mar 2011 17:14:19 +0100 [thread overview]
Message-ID: <20110302161419.GF22310@pengutronix.de> (raw)
In-Reply-To: <20110301142024.GB13983@jasper.tkos.co.il>
On Tue, Mar 01, 2011 at 04:20:25PM +0200, Baruch Siach wrote:
> Hi Marc,
>
> On Tue, Mar 01, 2011 at 03:11:31PM +0100, Marc Kleine-Budde wrote:
> > On 03/01/2011 03:06 PM, Vanalme Filip wrote:
> > [...]
> >
> > > One more question about barebox scripts (I guess even scripts in
> > > general...). This is part of a script from another board (that I took
> > > over for my own board):
> >
> > > #!/bin/sh
> > >
> > > . /env/config
> > >
> > > If [ x$1 = xflash ]; then
> > > root=flash
> > > kernel=flash
> > > fi
> > >
> > > if [ x$1 = xnet ]; then
> > > root=net
> > > kernel=net
> > > fi
> > >
> > > why the scripts are using i.e. [ x$1 = xflash ] instead of just simply [ $1 = flash ] ? Both are doing the same, no ?
> >
> > The shell is quite old and doesn't support that. But you're right for
> > modern shells like bash or dash.
>
> I get this under bash:
>
> $ [ $UNDEF = test ]
> bash: [: =: unary operator expected
>
> However '[ "$UNDEF" = test ]' behaves as expected under bash (but not under
> hush, which is the shell of Barebox).
I didn't test it, but even if a variable is defined, I guess this might
result in trouble:
arg=-n
[ $arg = flash ]
(At least I remember this being the reason for using "x$arg" back when I
worked on Solaris.)
And note without quoting quite interesting things can happen, e.g.:
test -n $arg
returns false if arg="= 42".
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-03-02 16:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-28 16:03 scripts Vanalme Filip
2011-02-28 16:09 ` scripts Marc Kleine-Budde
2011-02-28 16:12 ` scripts Marc Kleine-Budde
2011-03-01 8:02 ` scripts Vanalme Filip
2011-03-01 14:06 ` scripts Vanalme Filip
2011-03-01 14:11 ` scripts Marc Kleine-Budde
2011-03-01 14:20 ` scripts Baruch Siach
2011-03-02 16:14 ` Uwe Kleine-König [this message]
2011-03-02 8:36 ` scripts Vanalme Filip
2011-03-02 9:30 ` scripts Marc Kleine-Budde
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=20110302161419.GF22310@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=baruch@tkos.co.il \
/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