From 4cafa7d686454309bdc7a63591133a88817c3719 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 23 Aug 2013 21:35:27 +0200 Subject: m fix bash and java version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/argparser.bash | 13 ++++++++----- src/argparser/ArgParser.java | 8 +++++--- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/argparser.bash b/src/argparser.bash index c828360..72567a6 100644 --- a/src/argparser.bash +++ b/src/argparser.bash @@ -676,17 +676,20 @@ function args_parse if [ $argnull = 0 ]; then arg="${argqueue[$i]}" fi + std="$(head -n 1 < "${args_optmap}/${opt}")" + trigger="$(tail -n 1 < "${args_optmap}/${opt}")" + if (( ${#argqueue[@]} <= $i )); then + "$trigger" "${opt}" "${std}" + fi (( i++ )) - opt="$(head -n 1 < "${args_optmap}/${opt}")" + opt="${std}" if [ ! -e "${args_opts}/${opt}" ]; then mkdir -p "${args_opts}/${opt}" echo -n > "${args_opts}/${opt}/data" echo -n > "${args_opts}/${opt}/null" fi - if (( ${#argqueue[@]} >= $i )); then - echo "$arg" >> "${args_opts}/${opt}/data" - echo "$argnull" >> "${args_opts}/${opt}/null" - fi + echo "$arg" >> "${args_opts}/${opt}/data" + echo "$argnull" >> "${args_opts}/${opt}/null" done i=0 diff --git a/src/argparser/ArgParser.java b/src/argparser/ArgParser.java index 931e79f..fd97f81 100644 --- a/src/argparser/ArgParser.java +++ b/src/argparser/ArgParser.java @@ -1163,13 +1163,15 @@ public class ArgParser int i = 0, n = optqueue.size(); while (i < n) { - final String opt = this.optmap.get(optqueue.get(i)).standard; + final Option option = this.optmap.get(optqueue.get(i)); + final String opt = option.standard; final String arg = argqueue.size() > i ? argqueue.get(i) : null; + if (len(argqueue) <= i) + option.trigger(optqueue.get(i), null); i++; if (this.opts.get(opt) == null) this.opts.put(opt, new String[] {}); - if (argqueue.size() >= i) - this.opts.put(opt, append(this.opts.get(opt), arg)); + this.opts.put(opt, append(this.opts.get(opt), arg)); } for (final Option opt : this.options) -- cgit v1.2.3-70-g09d2