fff-gateway: some cosmetics

Submitted by Robert Langhammer on April 26, 2020, 7:10 p.m.

Details

Message ID 20200426191023.19047-1-rlanghammer@web.de
State New
Headers show

Commit Message

Robert Langhammer April 26, 2020, 7:10 p.m.
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

Patch hide | download patch | download mbox

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() {

Comments

Robert Langhammer April 26, 2020, 7:42 p.m.
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
>