summaryrefslogtreecommitdiff
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2018-07-01 18:43:06 +1000
committerMartin Schwenke <martins@samba.org>2018-07-28 03:50:10 +0200
commit4a39bc4aaad541f1e89c0eb3e98d4104bcc25025 (patch)
tree92c9d9780c4b522c6fc73bf26371e1da4a55fdb3 /ctdb/tools
parentdd9d8a20aa6948a5d1e7fb532842b7ff5bc0f550 (diff)
downloadsamba-4a39bc4aaad541f1e89c0eb3e98d4104bcc25025.tar.gz
ctdb-tools: Avoid use of non-portable getopt in onnode
getopt is being used with non-portable options. Use simpler, POSIX-compliant getopts instead. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13520 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tools')
-rwxr-xr-xctdb/tools/onnode53
1 files changed, 22 insertions, 31 deletions
diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode
index 50fc6a732d5..bef04b0fce0 100755
--- a/ctdb/tools/onnode
+++ b/ctdb/tools/onnode
@@ -72,39 +72,30 @@ fi
parse_options ()
{
- # $POSIXLY_CORRECT means that the command passed to onnode can
- # take options and getopt won't reorder things to make them
- # options ot onnode.
- local temp
- # Not on the previous line - local returns 0!
- temp=$(POSIXLY_CORRECT=1 getopt -n "$prog" -o "cf:hno:pqvPi" -l help -- "$@")
-
- # No! Checking the exit code afterwards is actually clearer...
- # shellcheck disable=SC2181
- [ $? -eq 0 ] || usage
-
- eval set -- "$temp"
-
- while true ; do
- case "$1" in
- -c) current=true ; shift ;;
- -f) ctdb_nodes_file="$2" ; shift 2 ;;
- -n) names_ok=true ; shift ;;
- -o) prefix="$2" ; shift 2 ;;
- -p) parallel=true ; shift ;;
- -q) quiet=true ; shift ;;
- -v) verbose=true ; shift ;;
- -P) push=true ; shift ;;
- -i) stdin=true ; shift ;;
- --) shift ; break ;;
- -h|--help|*) usage ;; # Shouldn't happen, so this is reasonable.
- esac
- done
+ local opt
+
+ while getopts "cf:hno:pqvPi?" opt ; do
+ case "$opt" in
+ c) current=true ;;
+ f) ctdb_nodes_file="$OPTARG" ;;
+ n) names_ok=true ;;
+ o) prefix="$OPTARG" ;;
+ p) parallel=true ;;
+ q) quiet=true ;;
+ v) verbose=true ;;
+ P) push=true ;;
+ i) stdin=true ;;
+ \?|h) usage ;;
+ esac
+ done
+ shift $((OPTIND - 1))
- [ $# -lt 2 ] && usage
+ if [ $# -lt 2 ] ; then
+ usage
+ fi
- nodespec="$1" ; shift
- command="$*"
+ nodespec="$1" ; shift
+ command="$*"
}
echo_nth ()