PT-76 Fixed cmd line parsing for lines having #

This commit is contained in:
Carlos Salguero
2017-02-25 13:52:46 -03:00
parent b118e39d10
commit 43a58c4c64
8 changed files with 22 additions and 8 deletions

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -173,6 +174,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -310,7 +312,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -214,6 +215,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -351,7 +353,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -314,7 +314,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -216,6 +217,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -353,7 +355,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -214,6 +215,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -351,7 +353,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -227,6 +228,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -364,7 +366,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
usage() { usage() {
@@ -182,6 +183,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
if [ ! -d "$PO_DIR" ]; then if [ ! -d "$PO_DIR" ]; then
@@ -319,7 +321,7 @@ _parse_config_files() {
echo "$config_opt" | grep '^[ ]*[^#]' >/dev/null 2>&1 || continue 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 [ "$config_opt" = "" ] && continue

View File

@@ -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_ERRS=0 # How many command line option errors
OPT_VERSION="" # If --version was specified OPT_VERSION="" # If --version was specified
OPT_HELP="" # If --help was specified OPT_HELP="" # If --help was specified
OPT_ASK_PASS="" # If --ask-pass was specified
PO_DIR="" # Directory with program option spec files PO_DIR="" # Directory with program option spec files
# Sub: usage # Sub: usage
@@ -182,6 +183,7 @@ parse_options() {
OPT_ERRS=0 OPT_ERRS=0
OPT_VERSION="" OPT_VERSION=""
OPT_HELP="" OPT_HELP=""
OPT_ASK_PASS=""
PO_DIR="$PT_TMPDIR/po" PO_DIR="$PT_TMPDIR/po"
# Ready the directory for the program option (po) spec files. # 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 =, # Strip leading and trailing spaces, and spaces around the first =,
# and end-of-line # comments. # 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. # Skip blank lines.
[ "$config_opt" = "" ] && continue [ "$config_opt" = "" ] && continue