[LEDE-DEV] [patch master 05/15] Use cd ... || exit in case cd fails
Bastian Bittorf
bb at npl.de
Sun Oct 2 11:02:47 PDT 2016
* Felix Fietkau <nbd at nbd.name> [02.10.2016 17:48]:
> >> +[ -n "$TOPDIR" ] && cd "$TOPDIR" || exit
> >>
> > these two are plain broken, as the script would just exit if TOPDIR is
> > empty. you need to use braces.
> I think a better approach would be to write a wrapper for cd, making it
> easier to read and review.
i dont think this is a good idea:
if your wrap a wrapper around a wrapper, you will make it
less readable and even more worse: you will confuse a static
checker like shellcheck.
dont see the checker like a "endmonster" you are fighting against.
so this means, even if we loose the 1-liner-contest:
[ -n "$TOPDIR" ] && {
cd "$TOPDIR" || errorhandler
}
bye, bastian
More information about the Lede-dev
mailing list