[maintainer-tools PATCH v2 33/33] dim: add -h option for usage, imrove output on unknown options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Show usage also with the -h option, and improve output on unknown
options.

Signed-off-by: Jani Nikula <jani.nikula@xxxxxxxxx>
---
 dim | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/dim b/dim
index 1651b5e8218a..fe1b2e8f1bad 100755
--- a/dim
+++ b/dim
@@ -107,6 +107,7 @@ DRY_RUN=
 INTERACTIVE=
 DRY=
 FORCE=
+HELP=
 
 function warn_or_fail
 {
@@ -118,7 +119,7 @@ function warn_or_fail
 	fi
 }
 
-while getopts dfi opt; do
+while getopts hdfi opt; do
 	case "$opt" in
 		d)
 			DRY_RUN=--dry-run
@@ -130,15 +131,18 @@ while getopts dfi opt; do
 		i)
 			INTERACTIVE='eval read -rsp "Press any key to continue..." -n1 key2; echo'
 			;;
+		h)
+			HELP=1
+			;;
 		*)
-			echo "Try 'dim help' for more information. $opt"
+			echo "See '$0 help' for more information." >&2
 			exit
 	esac
 done
 shift `expr $OPTIND - 1`
 
 # first positional argument is the subcommand
-if [ "$#" = "0" ]; then
+if [ -n "$HELP" -o "$#" = "0" ]; then
     subcommand="usage"
 else
     subcommand="$1"
-- 
2.1.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux