#! /bin/sh -e # @configure_input@ # Copyright (C) 2007 Noah Slater . # This file is free software; you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software # Foundation; either version 2 of the License, or (at your option) any later # version. # This file is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more # details. # You should have received a copy of the GNU General Public License along with # this file; if not, write to the Free Software Foundation, Inc., 51 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. SCRIPT_OK=0 SCRIPT_ERROR=1 DEFAULT_VERSION=170 display_version () { # Display version and copyright information. cat << EOF couchjs - %package_name% %version% Copyright (C) 2007 %package_author_name% <%package_author_address%>. Copyright (C) 1998 Netscape Communications Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the Mozilla Public License as published by the Mozilla Foundation; either version 1.1 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Mozilla Public License for more details. You may obtain a copy of the License at . Written by %package_author_name% <%package_author_address%> and the Netscape Communications Corporation. EOF } display_help () { # Display a short description of the script's behaviour. basename=$1 cat << EOF Usage: $basename [OPTION]... [FILE] [ARG]... The $basename command runs the %package_name% JavaScript interpreter shell. %package_name% uses a custom version of the SpiderMonkey engine originally writen by the Netscape Communications Corporation. For more details about SpiderMonkey see: The exit status is 0 for success or 1 for failure. Options: -h display a short help message and exit -V display version information and exit -b LIMIT set the branch LIMIT -c SIZE set the stack chunk SIZE -C compile the program but do not run it -e STRING execute the literal STRING -f FILE run the JavaScript program FILE -i enable interactive mode -s enable strict warning mode -S SIZE set the maximum stack SIZE -v VERSION set the JavaScript version (defaults to 170 for JavaScript 1.7) -w enable warning messages -W disable warning messages -x enable E4X XML mode Report bugs via the web at <%list_uri%>. Report bugs via email to <%list_address%>. EOF } display_error () { # Display a short instruction referring users to further documentation. basename=$1 echo "Try \`"$basename" -h' for more information." } run_couchjs () { # Run the JavaScript interpreter shell with options. %libbindir%/%_couchjs_command_name% $@ } parse_script_option_list () { # Parse the script option list and take the appropriate action. basename=$(basename $0) if ! argument_list=$(getopt hVbcCefisSvwWx $@); then echo display_error $basename exit $SCRIPT_ERROR fi eval set -- "$argument_list" while [ $# -gt 0 ]; do case "$1" in -h) shift display_help $basename exit $SCRIPT_OK ;; -V) shift display_version exit $SCRIPT_OK ;; -v) shift DEFAULT_VERSION=$1 shift ;; --) shift break ;; *) break ;; esac done option_list=$(echo $@ | sed 's/--//') run_couchjs -v $DEFAULT_VERSION $option_list } parse_script_option_list $@