[LEDE-DEV] [patch master 05/15] Use cd ... || exit in case cd fails

Felix Fietkau nbd at nbd.name
Sat Oct 1 01:54:17 PDT 2016


On 2016-10-01 09:44, Oswald Buddenhagen wrote:
> On Fri, Sep 30, 2016 at 10:02:19PM +0200, Jan-Tarek Butt wrote:
>> diff --git a/scripts/get_source_date_epoch.sh b/scripts/get_source_date_epoch.sh
>> -[ -n "$TOPDIR" ] && cd "$TOPDIR"
>> +[ -n "$TOPDIR" ] && cd "$TOPDIR" || exit
>> diff --git a/scripts/getver.sh b/scripts/getver.sh
>> -[ -n "$TOPDIR" ] && cd "$TOPDIR"
>> +[ -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.

- Felix




More information about the Lede-dev mailing list