diff mbox series

[OpenWrt-Devel,v4] base-files: make wifi report unknown command

Message ID 20180809183345.2611-1-hacks@slashdirt.org
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel,v4] base-files: make wifi report unknown command | expand

Commit Message

Thibaut Aug. 9, 2018, 6:33 p.m. UTC
Avoid having /sbin/wifi silently ignore unknown keywords and execute
"up"; instead display the help message and exit with an error.

Spell out the "up" keyword (which has users), add it to usage output,
and preserve the implicit assumption that runing /sbin/wifi without
argument performs "up".

Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
---
 package/base-files/files/sbin/wifi | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Karl Palsson Aug. 10, 2018, 11:12 a.m. UTC | #1
Thibaut VARÈNE  <hacks@slashdirt.org> wrote:
> Avoid having /sbin/wifi silently ignore unknown keywords and
> execute "up"; instead display the help message and exit with an
> error.
> 
> Spell out the "up" keyword (which has users), add it to usage
> output, and preserve the implicit assumption that runing
> /sbin/wifi without argument performs "up".
> 
> Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
> ---
>  package/base-files/files/sbin/wifi | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/package/base-files/files/sbin/wifi
> b/package/base-files/files/sbin/wifi index
> 83befc0d6f..f7a10de215 100755
> --- a/package/base-files/files/sbin/wifi
> +++ b/package/base-files/files/sbin/wifi
> @@ -6,7 +6,7 @@
>  
>  usage() {
>  	cat <<EOF
> -Usage: $0 [config|down|reload|status]
> +Usage: $0 [config|up|down|reload|status]
>  enables (default), disables or configures devices not yet configured.

so, which one is "enable" is it config, up, down, reload, or
status? Perhaps update this to say which command is the default?

>  EOF
>  	exit 1
> @@ -241,5 +241,6 @@ case "$1" in
>  	reload) wifi_reload "$2";;
>  	reload_legacy) wifi_reload_legacy "$2";;
>  	--help|help) usage;;
> -	*) ubus call network reload; wifi_updown "enable" "$2";;
> +	''|up) ubus call network reload; wifi_updown "enable" "$2";;
> +	*) usage; exit 1;;
>  esac
> -- 
> 2.14.3 (Apple Git-98)
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
diff mbox series

Patch

diff --git a/package/base-files/files/sbin/wifi b/package/base-files/files/sbin/wifi
index 83befc0d6f..f7a10de215 100755
--- a/package/base-files/files/sbin/wifi
+++ b/package/base-files/files/sbin/wifi
@@ -6,7 +6,7 @@ 
 
 usage() {
 	cat <<EOF
-Usage: $0 [config|down|reload|status]
+Usage: $0 [config|up|down|reload|status]
 enables (default), disables or configures devices not yet configured.
 EOF
 	exit 1
@@ -241,5 +241,6 @@  case "$1" in
 	reload) wifi_reload "$2";;
 	reload_legacy) wifi_reload_legacy "$2";;
 	--help|help) usage;;
-	*) ubus call network reload; wifi_updown "enable" "$2";;
+	''|up) ubus call network reload; wifi_updown "enable" "$2";;
+	*) usage; exit 1;;
 esac