Fixed shellcheck issue SC2015: Note that A && B || C is not if-then-else. C may run when A is true.

Replaced [ $1 -gt 1 ] && shift $1 || shift with shift $1 since
shift 1 is identical to shift.
This commit is contained in:
Dundar Göc 2021-02-13 22:37:28 +01:00
parent 48052e2f24
commit 8aa4607e5e
2 changed files with 2 additions and 2 deletions

View file

@ -1810,7 +1810,7 @@ askEncryption(){
cidrToMask(){ cidrToMask(){
# Source: https://stackoverflow.com/a/20767392 # Source: https://stackoverflow.com/a/20767392
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[ $1 -gt 1 ] && shift $1 || shift shift $1
echo ${1-0}.${2-0}.${3-0}.${4-0} echo ${1-0}.${2-0}.${3-0}.${4-0}
} }

View file

@ -422,7 +422,7 @@ fi
cidrToMask(){ cidrToMask(){
# Source: https://stackoverflow.com/a/20767392 # Source: https://stackoverflow.com/a/20767392
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[ $1 -gt 1 ] && shift $1 || shift shift $1
echo ${1-0}.${2-0}.${3-0}.${4-0} echo ${1-0}.${2-0}.${3-0}.${4-0}
} }