From 43a58c4c64a022cc95f540319ec8aa7e0feb7b56 Mon Sep 17 00:00:00 2001 From: Carlos Salguero Date: Sat, 25 Feb 2017 13:52:46 -0300 Subject: [PATCH] PT-76 Fixed cmd line parsing for lines having # --- bin/pt-ioprofile | 4 +++- bin/pt-mext | 4 +++- bin/pt-mysql-summary | 2 +- bin/pt-pmp | 4 +++- bin/pt-sift | 4 +++- bin/pt-stalk | 4 +++- bin/pt-summary | 4 +++- lib/bash/parse_options.sh | 4 +++- 8 files changed, 22 insertions(+), 8 deletions(-) diff --git a/bin/pt-ioprofile b/bin/pt-ioprofile index c755af6a..39524300 100755 --- a/bin/pt-ioprofile +++ b/bin/pt-ioprofile @@ -73,6 +73,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -173,6 +174,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -310,7 +312,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-mext b/bin/pt-mext index ed4b5575..ad4599a0 100755 --- a/bin/pt-mext +++ b/bin/pt-mext @@ -114,6 +114,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -214,6 +215,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -351,7 +353,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-mysql-summary b/bin/pt-mysql-summary index df133cf7..a1d1e130 100755 --- a/bin/pt-mysql-summary +++ b/bin/pt-mysql-summary @@ -314,7 +314,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-pmp b/bin/pt-pmp index ae0c50af..8a9ffe5b 100755 --- a/bin/pt-pmp +++ b/bin/pt-pmp @@ -116,6 +116,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -216,6 +217,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -353,7 +355,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-sift b/bin/pt-sift index 36da9f9f..6d2ea738 100755 --- a/bin/pt-sift +++ b/bin/pt-sift @@ -114,6 +114,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -214,6 +215,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -351,7 +353,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-stalk b/bin/pt-stalk index c0b07dc8..fd4c34df 100755 --- a/bin/pt-stalk +++ b/bin/pt-stalk @@ -127,6 +127,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -227,6 +228,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -364,7 +366,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/bin/pt-summary b/bin/pt-summary index 23afbba0..8355e3b7 100755 --- a/bin/pt-summary +++ b/bin/pt-summary @@ -82,6 +82,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files usage() { @@ -182,6 +183,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" if [ ! -d "$PO_DIR" ]; then @@ -319,7 +321,7 @@ _parse_config_files() { echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" [ "$config_opt" = "" ] && continue diff --git a/lib/bash/parse_options.sh b/lib/bash/parse_options.sh index eee9e154..a3e4beb4 100644 --- a/lib/bash/parse_options.sh +++ b/lib/bash/parse_options.sh @@ -54,6 +54,7 @@ HAVE_EXT_ARGV="" # Got --, everything else is put into EXT_ARGV OPT_ERRS=0 # How many command line option errors OPT_VERSION="" # If --version was specified OPT_HELP="" # If --help was specified +OPT_ASK_PASS="" # If --ask-pass was specified PO_DIR="" # Directory with program option spec files # Sub: usage @@ -182,6 +183,7 @@ parse_options() { OPT_ERRS=0 OPT_VERSION="" OPT_HELP="" + OPT_ASK_PASS="" PO_DIR="$PT_TMPDIR/po" # Ready the directory for the program option (po) spec files. @@ -346,7 +348,7 @@ _parse_config_files() { # Strip leading and trailing spaces, and spaces around the first =, # and end-of-line # comments. - config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]*#.*$//')" + config_opt="$(echo "$config_opt" | sed -e 's/^ *//g' -e 's/ *$//g' -e 's/[ ]*=[ ]*/=/' -e 's/[ ]+#.*$//')" # Skip blank lines. [ "$config_opt" = "" ] && continue