Closed GoogleCodeExporter closed 9 years ago
Interesting, it must be an error in the command-line option parsing code. What
do you get if you do this?
. ./diskstats
generate_parse_options ./diskstats
And what is your awk and bash version, and operating system version?
Original comment by baron.schwartz
on 6 Feb 2011 at 10:09
It's a stock RHEL 5.6 x86-64, with stock awk and bash:
$ bash --version
GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2005 Free Software Foundation, Inc.
$ awk --version
GNU Awk 3.1.5
Output of "generate_parse_options ./diskstats"
for o; do
case "${o}" in
--)
shift; break;
;;
--help)
usage;
;;
-c)
shift; OPT_c="${1}"; shift;
;;
-d)
shift; OPT_d="${1}"; shift;
;;
-g)
shift; OPT_g="${1}"; shift;
case "${OPT_g}" in
disk)
;;
sample)
;;
all)
;;
*)
OPT_ERR="Bad option value";
usage
;;
esac
;;
-i)
shift; OPT_i="${1}"; shift;
;;
-k)
shift; OPT_k="${1}"; shift;
;;
-n)
shift; OPT_n="${1}"; shift;
;;
-s)
shift; OPT_s="${1}"; shift;
;;
-*)
OPT_ERR="Unknown option ${o}."
usage
;;
esac
done
export OPT_i="${OPT_i:-}";
export OPT_k="${OPT_k:-/tmp/aspersa}";
export OPT_n="${OPT_n:-}";
export OPT_c="${OPT_c:-cnc|rt|mb|busy|prg}";
export OPT_d="${OPT_d:-}";
export OPT_s="${OPT_s:-1}";
export OPT_g="${OPT_g:-disk}";
Original comment by fig...@gmail.com
on 6 Feb 2011 at 12:06
Hm, that's interesting. I can repro it easily on a CentOS virtual box too. I
fixed it. Apparently sourcing a file isn't a good way to parse command-line
options.
Original comment by baron.schwartz
on 6 Feb 2011 at 1:08
This issue was updated by revision r336.
Embed option-parsing code directly into tools
Original comment by baron.schwartz
on 6 Feb 2011 at 1:27
Yes, it fixed the issue. Thanks for the quick response!
Original comment by fig...@gmail.com
on 6 Feb 2011 at 3:01
I'm going to just include the generated command-line code directly instead of
making it magically generate and source the code. No further changes needed to
the code.
Original comment by baron.schwartz
on 10 Feb 2011 at 1:56
Original issue reported on code.google.com by
fig...@gmail.com
on 6 Feb 2011 at 6:36