[OpenWrt-Devel] [PATCH 2/5] scripts/env: replace -a and -o with &&/||

Rosen Penev rosenp at gmail.com
Wed Jan 1 18:09:26 EST 2020


On Wed, Jan 1, 2020 at 5:47 AM Paul Oranje <por at oranjevos.nl> wrote:
>
> Happy new year !
>
> A minor question/nitpick, see below.
> Regards
>
> > Op 1 jan. 2020, om 03:01 heeft Rosen Penev <rosenp at gmail.com> het volgende geschreven:
> >
> > The former are not well defined.
> >
> > Found with shellcheck.
> [skip]
>
> > -                     [ -d "$BASEDIR/files" -a \! -L "$BASEDIR/files" ] && {
> > +                     if [ -d "$BASEDIR/files" ] && [ \! -L "$BASEDIR/files" ]; then
> >                               mkdir -p "$ENVDIR/files"
> >                               shopt -s dotglob
> >                               mv "$BASEDIR/files/"* "$ENVDIR/files/" 2>/dev/null
> >                               shopt -u dotglob
> >                               rmdir "$BASEDIR/files"
> > -                     }
> > +                     fi
> Why has " ... && { ... }" syntax been replaced with "if ... then ... fi" ?
> Both forms are used in the script anyway.
It's clearer. One issue with replacing -a with && is the case of [ 1
-a 2 ] ||. [ 1 ] && [ 2 ] || has the wrong behaviour. It's not the
case here but generally speaking it's more correct to replace with an
if statement.

Please also Reply to All next time.
>
> [skip]

_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list