[arch-projects] [netcfg] [PATCH] Exit from stop_wpa() if there's nothing to terminate.

Dave Reisner d at falconindy.com
Wed Oct 3 15:55:12 EDT 2012


On Wed, Oct 03, 2012 at 11:33:15PM +0400, Ivan Shapovalov wrote:
> On Tuesday 02 October 2012 15:12:29 Dave Reisner wrote:
> > On Tue, Oct 02, 2012 at 10:27:24PM +0400, Ivan Shapovalov wrote:
> > > Check "$WPA_CONF_DIR/$INTERFACE" for existence; exit if it's absent
> > > (that is, wpa_supplicant isn't running).
> > > Just avoids an error message from wpa_cli.
> > > 
> > > Signed-off-by: Ivan Shapovalov <intelfx100 at gmail.com>
> > > ---
> > > 
> > >  src/8021x | 3 +++
> > >  1 file changed, 3 insertions(+)
> > > 
> > > diff --git a/src/8021x b/src/8021x
> > > index 608d683..bce4e8c 100644
> > > --- a/src/8021x
> > > +++ b/src/8021x
> > > @@ -73,6 +73,9 @@ stop_wpa()
> > > 
> > >      # we need this as long as wpa_cli has a different default than netcfg
> > >      [[ -z "$WPA_CTRL_DIR" && -z "$WPA_CONF" ]] &&
> > >      WPA_CTRL_DIR="/run/wpa_supplicant"> 
> > > +    # exit if wpa_supplicant is already terminated for this interface
> > > +    [ -e "$WPA_CTRL_DIR/$INTERFACE" ] || return
> > 
> > It baffles me why people blatently disregard syntax. [ is not identical
> > to [[ in bash.
> 
> [ is POSIX while [[ is bash (and it gives some extra functions).

Look at the shebang. Are you writing POSIX sh or bash?

[[ is also a keyword in bash (not a builtin), meaning it's handled by
the lexer. Because of this, it enjoys slightly different (generally more
lax) quoting semantics, and it's also measurably faster when you
consider the number of times that this basic construct of the language
is used throughout any given script.

> I'm not using the extra functions of the latter here, so why need to use [[ ?

In this case, it's mostly a matter of respecting the style of the rest
of the project. Grep through the source -- there's exactly 2 other
instances of a single bracket being used and they're both in a contrib
file.

> > 
> > > +
> > > 
> > >      wpa_call "$INTERFACE" terminate > /dev/null
> > >      
> > >      # wait up to one second for the pid file to be removed


More information about the arch-projects mailing list