[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] py-compile: '--' and non-option arguments terminate the opti
From: |
Stefano Lattarini |
Subject: |
[PATCH 6/6] py-compile: '--' and non-option arguments terminate the option list |
Date: |
Thu, 9 Jun 2011 16:15:27 +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 | 9 ++++++
NEWS | 2 +
lib/py-compile | 8 ++++-
tests/Makefile.am | 1 +
tests/Makefile.in | 1 +
tests/py-compile-option-terminate.test | 44 ++++++++++++++++++++++++++++++++
6 files changed, 63 insertions(+), 2 deletions(-)
create mode 100755 tests/py-compile-option-terminate.test
diff --git a/ChangeLog b/ChangeLog
index a530cb8..b77853f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-06-08 Stefano Lattarini <address@hidden>
+ 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 <address@hidden>
+
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 <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
+
+:
--
1.7.2.3
- [PATCH 0/6] Some python patches, Stefano Lattarini, 2011/06/09
- [PATCH 2/6] py-compile: the '--destdir' option now accepts a blank argument, Stefano Lattarini, 2011/06/09
- [PATCH 4/6] py-compile: normalize error and help messages, Stefano Lattarini, 2011/06/09
- [PATCH 5/6] py-compile: complain on unrecognized options, Stefano Lattarini, 2011/06/09
- [PATCH 1/6] python: run the 'py-compile' script with $(SHELL), Stefano Lattarini, 2011/06/09
- [PATCH 3/6] python tests: add "unit tests" on py-compile, Stefano Lattarini, 2011/06/09
- [PATCH 6/6] py-compile: '--' and non-option arguments terminate the option list,
Stefano Lattarini <=
- Re: [PATCH 0/6] Some python patches, Stefano Lattarini, 2011/06/12