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,31 +74,35 @@ parse_options() {
mkdir $TMPDIR/po/ 2>/dev/null mkdir $TMPDIR/po/ 2>/dev/null
rm -rf $TMPDIR/po/* rm -rf $TMPDIR/po/*
awk -v "po_dir"="$TMPDIR/po" ' (
/^=head1 OPTIONS/ { export LC_ALL="C"
getline
while ($0 !~ /^=head1/) {
if ($0 ~ /^=item --.*/) {
long_opt = substr($2, 3, length($2) - 2)
spec_file = po_dir "/" long_opt
trf = "sed -e \"s/[ ]//g\" | tr \";\" \"\n\" > " spec_file
getline # blank line awk -v "po_dir"="$TMPDIR/po" '
getline # specs or description /^=head1 OPTIONS/ {
if ($0 ~ /^[a-z]/ ) {
print "long:" long_opt "; " $0 | trf
close(trf)
}
else {
print "long:" long_opt > spec_file
close(spec_file)
}
}
getline getline
} while ($0 !~ /^=head1/) {
exit if ($0 ~ /^=item --.*/) {
}' $file long_opt = substr($2, 3, length($2) - 2)
spec_file = po_dir "/" long_opt
trf = "sed -e \"s/[ ]//g\" | tr \";\" \"\n\" > " spec_file
getline # blank line
getline # specs or description
if ($0 ~ /^[a-z]/ ) {
print "long:" long_opt "; " $0 | trf
close(trf)
}
else {
print "long:" long_opt > spec_file
close(spec_file)
}
}
getline
}
exit
}' $file
)
for opt_spec in $(ls $TMPDIR/po/); do for opt_spec in $(ls $TMPDIR/po/); do
local opt="" local opt=""

View File

@@ -82,33 +82,39 @@ parse_options() {
# from the option's POD line like "type: string; default: foo". # from the option's POD line like "type: string; default: foo".
mkdir $TMPDIR/po/ 2>/dev/null mkdir $TMPDIR/po/ 2>/dev/null
rm -rf $TMPDIR/po/* rm -rf $TMPDIR/po/*
awk -v "po_dir"="$TMPDIR/po" ' (
/^=head1 OPTIONS/ { # awk is stupid on some systems (e.g. Ubuntu 10) such that
getline # /^[a-z]/ incorrectly matches "Foo". This fixes that.
while ($0 !~ /^=head1/) { export LC_ALL="C"
if ($0 ~ /^=item --.*/) {
long_opt = substr($2, 3, length($2) - 2)
spec_file = po_dir "/" long_opt
trf = "sed -e \"s/[ ]//g\" | tr \";\" \"\n\" > " spec_file
getline # blank line awk -v "po_dir"="$TMPDIR/po" '
getline # specs or description /^=head1 OPTIONS/ {
if ($0 ~ /^[a-z]/ ) {
# spec line like "type: int; default: 100"
print "long:" long_opt "; " $0 | trf
close(trf)
}
else {
# no specs, should be description of option
print "long:" long_opt > spec_file
close(spec_file)
}
}
getline getline
} while ($0 !~ /^=head1/) {
exit if ($0 ~ /^=item --.*/) {
}' $file long_opt = substr($2, 3, length($2) - 2)
spec_file = po_dir "/" long_opt
trf = "sed -e \"s/[ ]//g\" | tr \";\" \"\n\" > " spec_file
getline # blank line
getline # specs or description
if ($0 ~ /^[a-z]/ ) {
# spec line like "type: int; default: 100"
print "long:" long_opt "; " $0 | trf
close(trf)
}
else {
# no specs, should be description of option
print "long:" long_opt > spec_file
close(spec_file)
}
}
getline
}
exit
}' $file
)
# Evaluate the program options into existence as global variables # Evaluate the program options into existence as global variables
# transformed like --my-op == $OPT_MY_OP. If an option has a default # transformed like --my-op == $OPT_MY_OP. If an option has a default