From: Stefano Lattarini Date: Wed, 8 Jun 2011 20:27:25 +0000 (+0200) Subject: py-compile: '--' and non-option arguments terminate the option list X-Git-Tag: v1.12.0b~272^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a2ebf0e5b1f34d76ce92673cf8575a10d33f9b05;p=platform%2Fupstream%2Fautomake.git py-compile: '--' and non-option arguments terminate the option list * lib/py-compile: Any non-option argument, or the special `--' argument, now explicitly terminates the list of options. * tests/py-compile-option-terminate.test: New test. * tests/Makefile.am (TESTS): Update. * NEWS: Update. --- diff --git a/ChangeLog b/ChangeLog index a530cb8..b77853f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-06-08 Stefano Lattarini + py-compile: '--' and non-option arguments terminate the option list + * lib/py-compile: Any non-option argument, or the special `--' + argument, now explicitly terminates the list of options. + * tests/py-compile-option-terminate.test: New test. + * tests/Makefile.am (TESTS): Update. + * NEWS: Update. + +2011-06-08 Stefano Lattarini + py-compile: complain on unrecognized options * lib/py-compile: Complain on unrecognized options. Don't be too lax in matching `--help' and `--version' options. diff --git a/NEWS b/NEWS index 745c6c7..db65048 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,8 @@ New in 1.11.0a: - The py-compile script now accepts empty arguments passed to the options `--destdir' and `--basedir', and complains about unrecognized options. + Moreover, a non-option argument or a special `--' arguments terminates + the list of options. Bugs fixed in 1.11.0a: diff --git a/lib/py-compile b/lib/py-compile index 7aa2425..15c834c 100755 --- a/lib/py-compile +++ b/lib/py-compile @@ -43,7 +43,6 @@ usage_error () basedir= destdir= -files= while test $# -ne 0; do case "$1" in --basedir) @@ -82,16 +81,21 @@ EOF echo "$me $scriptversion" exit $? ;; + --) + shift + break + ;; -*) usage_error "unrecognized option '$1'" ;; *) - files="$files $1" + break ;; esac shift done +files=$* if test -z "$files"; then usage_error "no files given" fi diff --git a/tests/Makefile.am b/tests/Makefile.am index 829e960..b2d36ff 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -638,6 +638,7 @@ py-compile-basic2.test \ py-compile-basedir.test \ py-compile-destdir.test \ py-compile-env.test \ +py-compile-option-terminate.test \ py-compile-usage.test \ python.test \ python2.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 47a334e..7eb545a 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -909,6 +909,7 @@ py-compile-basic2.test \ py-compile-basedir.test \ py-compile-destdir.test \ py-compile-env.test \ +py-compile-option-terminate.test \ py-compile-usage.test \ python.test \ python2.test \ diff --git a/tests/py-compile-option-terminate.test b/tests/py-compile-option-terminate.test new file mode 100755 index 0000000..6fdd1fb --- /dev/null +++ b/tests/py-compile-option-terminate.test @@ -0,0 +1,44 @@ +#! /bin/sh +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program 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, 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 +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Check that a `--' argument explicitly terminates option list for +# `py-compile'. + +required=python +. ./defs || Exit 1 + +set -e + +cp "$testsrcdir/../lib/py-compile" . + +: > ./-o.py +: > ./--foo.py +./py-compile -- -o.py --foo.py +test -f ./-o.pyc +test -f ./-o.pyo +test -f ./--foo.pyc +test -f ./--foo.pyo +rm -f ./-*.py[co] +: > x.py +./py-compile x.py -o.py --foo.py +test -f ./x.pyc +test -f ./x.pyo +test -f ./-o.pyc +test -f ./-o.pyo +test -f ./--foo.pyc +test -f ./--foo.pyo + +: