diff --git a/webshell/tests/viewer/mozilla-viewer.sh b/webshell/tests/viewer/mozilla-viewer.sh index 7911d8fed8dd..d06d4cd24eaf 100755 --- a/webshell/tests/viewer/mozilla-viewer.sh +++ b/webshell/tests/viewer/mozilla-viewer.sh @@ -33,35 +33,41 @@ dist_bin="" # Running from dist/bin if [ -d components -a -d res ] then - dist_bin="./" + dist_bin="./" else - # Running from source dir - if [ -f Makefile.in ] - then - dist_bin=`grep -w DEPTH Makefile.in | grep -e "\.\." | awk -F"=" '{ print $2; }'`/dist/bin - fi + # Running from source dir + if [ -f Makefile.in ] + then + depth=`perl -ne '/^DEPTH\s*=(.*)/ and print $1' Makefile.in` + dist_bin=$depth/dist/bin + fi fi script_args="" -while [ -n "$(echo $1 | grep '^-')" ] +while [ $# -gt 0 ] do - case $1 in - -h | --help) - script_args="$script_args -h" - ;; - - -g | --debug) - script_args="$script_args -g" - ;; - - -d | --debugger) - script_args="$script_args -d $2" - - shift - ;; - esac - shift + case $1 in + -h | --help) + script_args="$script_args -h" + shift + ;; + -g | --debug) + script_args="$script_args -g" + shift + ;; + -d | --debugger) + script_args="$script_args -d $2" + shift 2 + ;; + -*) + echo "Unknown option: $1" 1>&2 + exit 1 + ;; + *) + break + ;; + esac done $dist_bin/run-mozilla.sh $script_args ./viewer ${1+"$@"}