mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-10 05:00:45 +00:00
Merge ~daniel-nichter/percona-toolkit/bash-tool-libs r123.
This commit is contained in:
50
bin/pt-stalk
50
bin/pt-stalk
@@ -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=""
|
||||||
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user