py-compile: '--' and non-option arguments terminate the option list
authorStefano Lattarini <stefano.lattarini@gmail.com>
Wed, 8 Jun 2011 20:27:25 +0000 (22:27 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 9 Jun 2011 14:00:40 +0000 (16:00 +0200)
* 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.

ChangeLog
NEWS
lib/py-compile
tests/Makefile.am
tests/Makefile.in
tests/py-compile-option-terminate.test [new file with mode: 0755]

index a530cb8..b77853f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-06-08  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
+       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  <stefano.lattarini@gmail.com>
+
        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 (file)
--- 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:
 
index 7aa2425..15c834c 100755 (executable)
@@ -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
index 829e960..b2d36ff 100644 (file)
@@ -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 \
index 47a334e..7eb545a 100644 (file)
@@ -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 (executable)
index 0000000..6fdd1fb
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+# 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
+
+: