netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: David Laight <David.Laight@ACULAB.COM>
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [iproute PATCH v2 2/2] ifcfg: Quote left-hand side of [ ] expression
Date: Fri, 18 Aug 2017 13:24:14 +0200	[thread overview]
Message-ID: <20170818112414.GJ10864@orbyte.nwl.cc> (raw)
In-Reply-To: <063D6719AE5E284EB5DD2968C1650D6DD005A809@AcuExch.aculab.com>

On Fri, Aug 18, 2017 at 09:32:52AM +0000, David Laight wrote:
> From: Phil Sutter
> > Sent: 17 August 2017 18:10
> > This prevents word-splitting and therefore leads to more accurate error
> > message in case 'grep -c' prints something other than a number.
> > 
> > Signed-off-by: Phil Sutter <phil@nwl.cc>
> > ---
> >  ip/ifcfg | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/ip/ifcfg b/ip/ifcfg
> > index 083d9df36742f..30a2dc49816cd 100644
> > --- a/ip/ifcfg
> > +++ b/ip/ifcfg
> > @@ -131,7 +131,7 @@ noarp=$?
> > 
> >  ip route add unreachable 224.0.0.0/24 >& /dev/null
> >  ip route add unreachable 255.255.255.255 >& /dev/null
> > -if [ `ip link ls $dev | grep -c MULTICAST` -ge 1 ]; then
> > +if [ "`ip link ls $dev | grep -c MULTICAST`" -ge 1 ]; then
> 
> You could drag all these scripts into the 1990's by using $(...)
> instead of `...`.

That's a different kettle of fish IMO, using $() doesn't change the
situation this addresses:

| $ [ $(echo foo bar) -eq 0 ] && echo ok
| bash: [: too many arguments
| $ [ "$(echo foo bar)" -eq 0 ] && echo ok
| bash: [: foo bar: integer expression expected

Cheers, Phil

  reply	other threads:[~2017-08-18 11:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-17 17:09 [iproute PATCH v2 0/2] Covscan: Shell script fixes Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 1/2] examples: Some shell fixes to cbq.init Phil Sutter
2017-08-17 17:09 ` [iproute PATCH v2 2/2] ifcfg: Quote left-hand side of [ ] expression Phil Sutter
2017-08-18  9:32   ` David Laight
2017-08-18 11:24     ` Phil Sutter [this message]
2017-08-18 16:38       ` David Laight
2017-08-18 16:12 ` [iproute PATCH v2 0/2] Covscan: Shell script fixes Stephen Hemminger

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=20170818112414.GJ10864@orbyte.nwl.cc \
    --to=phil@nwl.cc \
    --cc=David.Laight@ACULAB.COM \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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).