Merge ~daniel-nichter/percona-toolkit/bash-tool-libs r123.

This commit is contained in:
Daniel Nichter
2011-12-07 11:59:39 -07:00
2 changed files with 58 additions and 48 deletions

View File

@@ -74,6 +74,9 @@ parse_options() {
mkdir $TMPDIR/po/ 2>/dev/null
rm -rf $TMPDIR/po/*
(
export LC_ALL="C"
awk -v "po_dir"="$TMPDIR/po" '
/^=head1 OPTIONS/ {
getline
@@ -99,6 +102,7 @@ parse_options() {
}
exit
}' $file
)
for opt_spec in $(ls $TMPDIR/po/); do
local opt=""

View File

@@ -82,6 +82,11 @@ parse_options() {
# from the option's POD line like "type: string; default: foo".
mkdir $TMPDIR/po/ 2>/dev/null
rm -rf $TMPDIR/po/*
(
# awk is stupid on some systems (e.g. Ubuntu 10) such that
# /^[a-z]/ incorrectly matches "Foo". This fixes that.
export LC_ALL="C"
awk -v "po_dir"="$TMPDIR/po" '
/^=head1 OPTIONS/ {
getline
@@ -109,6 +114,7 @@ parse_options() {
}
exit
}' $file
)
# Evaluate the program options into existence as global variables
# transformed like --my-op == $OPT_MY_OP. If an option has a default