Message ID | 20200426191023.19047-1-rlanghammer@web.de |
---|---|
State | New |
Headers | show |
diff --git a/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway b/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway index 3594a44..5230888 100755 --- a/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway +++ b/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway @@ -40,14 +40,14 @@ execute_subshell() { configure() { echo "This script might remove existing vlans, interfaces, addresses, etc." read -r -p "Do you really want to continue? (y/n) " response - if ! ( [ "$response" == "y" ] || [ "$response" == "Y" ] ); then - exit 1 - fi - - echo - execute_subshell configure - - exit 0 + case "$response" in + [Yy]) + echo + execute_subshell configure + exit 0 ;; + *) + exit 1 ;; + esac } reload_services() {
Hi, es gäbe noch die ganz kurze Version. Dann allerdings nicht mehr so leicht zu lesen: - if ! ( [ "$response" == "y" ] || [ "$response" == "Y" ] ); then - exit 1 - fi + case "$response" in [!Yy]) exit 1 ;; esac echo execute_subshell configure Zur Abstimmung freigegeben :-) Gruß Robert Am 26.04.20 um 21:10 schrieb Robert Langhammer: > The construct of if, ! and tests with some "||" are often hard to read. Let's use a simple and easy reading equivalent. > > Signed-off-by: Robert Langhammer <rlanghammer@web.de> > --- > .../fff-gateway/files/usr/sbin/configuregateway | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway b/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway > index 3594a44..5230888 100755 > --- a/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway > +++ b/src/packages/fff/fff-gateway/files/usr/sbin/configuregateway > @@ -40,14 +40,14 @@ execute_subshell() { > configure() { > echo "This script might remove existing vlans, interfaces, addresses, etc." > read -r -p "Do you really want to continue? (y/n) " response > - if ! ( [ "$response" == "y" ] || [ "$response" == "Y" ] ); then > - exit 1 > - fi > - > - echo > - execute_subshell configure > - > - exit 0 > + case "$response" in > + [Yy]) > + echo > + execute_subshell configure > + exit 0 ;; > + *) > + exit 1 ;; > + esac > } > > reload_services() { > -- > 2.20.1 >
The construct of if, ! and tests with some "||" are often hard to read. Let's use a simple and easy reading equivalent. Signed-off-by: Robert Langhammer <rlanghammer@web.de> --- .../fff-gateway/files/usr/sbin/configuregateway | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) -- 2.20.1