From: George Dunlap <george.dunlap@citrix.com>
To: Mike Latimer <mlatimer@suse.com>, xen-devel@lists.xen.org
Cc: "Wei Liu" <wei.liu2@citrix.com>,
"Ian Campbell" <ian.campbell@citrix.com>,
"Stefano Stabellini" <stefano.stabellini@eu.citrix.com>,
"George Dunlap" <George.Dunlap@eu.citrix.com>,
"Ian Jackson" <ian.jackson@eu.citrix.com>,
"Roger Pau Monné" <roger.pau@citrix.com>
Subject: Re: [PATCH 1/1] tools/hotplug: Scan xenstore once when attaching shared images files
Date: Thu, 1 Oct 2015 16:27:53 +0100 [thread overview]
Message-ID: <560D50F9.9040403@citrix.com> (raw)
In-Reply-To: <4403884.Qk2JWoDYKM@mlatimer1.dnsdhcp.provo.novell.com>
On 01/10/15 16:16, Mike Latimer wrote:
> Hi again,
>
> On Thursday, October 01, 2015 10:51:08 AM George Dunlap wrote:
>>>
>>> - if [ "$d" = "$devmm" ]
>>> + if [[ "$devmm" == *"$d,"* ]]
>>
>> Style nit: using [[ instead of [. TBH I prefer [[, but it's probably
>> better to be consistent with the rest of the file.
>
> I was about to change this to something like:
>
> if [ "$devmm" != ${devmm/$d/} ]
>
> but I'm a bit concerned about the potential size of the variables involved. If
> there are 500 devices with 5-7 characters per device, $devmm becomes a pretty
> large string. I'm not sure this bash substitution method is a great option. I
> also don't really want the hit of passing the variable to grep.
>
> According to one post I found benchmarking various types of tests [1], the two
> fastest options are:
>
> [[ $b == *$a* ]]
>
> case $b in *$a):;;esac
>
> I can implement a case statement, but that seems even less clean than the
> simple [[ ... ]] approach (since there is only one case we care about).
>
> As this is a #!/bin/bash script, is [[ ... ]] okay to use, or would you prefer
> to use the case statement? (If you have any other ideas, I'm open to that as
> well.)
Oh, right -- sorry, I didn't realize that the test you were using was
only available with [[ ]].
The maintainers (of which I'm not one) have the final say. I'd
personally be in favor of leaving it [[ ]] with a comment before each
one saying that the $b == *$a* format is only available in [[ ]], so
that no one comes later and "cleans it up".
I'd personally be even more happy if all the [ ] in the script were
magically changed to [[ ]]. :-)
-George
prev parent reply other threads:[~2015-10-01 15:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-30 21:10 [PATCH 0/1] Block script performance with shared image files Mike Latimer
2015-09-30 21:10 ` [PATCH 1/1] tools/hotplug: Scan xenstore once when attaching shared images files Mike Latimer
2015-10-01 9:51 ` George Dunlap
2015-10-01 9:58 ` George Dunlap
2015-10-01 14:32 ` Mike Latimer
2015-10-01 15:16 ` Mike Latimer
2015-10-01 15:27 ` George Dunlap [this message]
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=560D50F9.9040403@citrix.com \
--to=george.dunlap@citrix.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=mlatimer@suse.com \
--cc=roger.pau@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xen.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.