[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[automake-commit] branch master updated: py-compile: handle filenames wi
From: |
Mike Frysinger |
Subject: |
[automake-commit] branch master updated: py-compile: handle filenames with whitespace |
Date: |
Mon, 07 Feb 2022 21:51:50 -0500 |
This is an automated email from the git hooks/post-receive script.
vapier pushed a commit to branch master
in repository automake.
View the commit online:
https://git.savannah.gnu.org/gitweb/?p=automake.git;a=commitdiff;h=8a913c268e462a89509726dfeba2cba5e406793c
The following commit(s) were added to refs/heads/master by this push:
new 8a913c268 py-compile: handle filenames with whitespace
8a913c268 is described below
commit 8a913c268e462a89509726dfeba2cba5e406793c
Author: Mike Frysinger <vapier@gentoo.org>
AuthorDate: Sat Feb 5 23:43:38 2022 -0500
py-compile: handle filenames with whitespace
The list of files is put into a string and then split on whitespace.
Fix the way the list of files are passed to the compile script.
* lib/py-compile: Pass files as arguments, not as a string.
* t/py-compile-files.sh: New test.
---
lib/py-compile | 16 ++++++----------
t/py-compile-files.sh | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+), 10 deletions(-)
diff --git a/lib/py-compile b/lib/py-compile
index b5f317f15..ccf406235 100755
--- a/lib/py-compile
+++ b/lib/py-compile
@@ -1,7 +1,7 @@
#!/bin/sh
# py-compile - Compile a Python program
-scriptversion=2022-02-06.04; # UTC
+scriptversion=2022-02-06.05; # UTC
# Copyright (C) 2000-2022 Free Software Foundation, Inc.
@@ -100,8 +100,7 @@ EOF
shift
done
-files=$*
-if test -z "$files"; then
+if test $# -eq 0; then
usage_error "no files given"
fi
@@ -143,10 +142,8 @@ fi
$PYTHON -c "
import sys, os, py_compile, $import_lib
-files = '''$files'''
-
sys.stdout.write('Byte-compiling python modules...\n')
-for file in files.split():
+for file in sys.argv[1:]:
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
@@ -158,7 +155,7 @@ for file in files.split():
py_compile.compile(filepath, $import_call(filepath), path)
else:
py_compile.compile(filepath, filepath + 'c', path)
-sys.stdout.write('\n')" || exit $?
+sys.stdout.write('\n')" "$@" || exit $?
# this will fail for python < 1.5, but that doesn't matter ...
$PYTHON -O -c "
@@ -168,9 +165,8 @@ import sys, os, py_compile, $import_lib
if hasattr(sys, 'pypy_translation_info'):
sys.exit(0)
-files = '''$files'''
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
-for file in files.split():
+for file in sys.argv[1:]:
$pathtrans
$filetrans
if not os.path.exists(filepath) or not (len(filepath) >= 3
@@ -182,7 +178,7 @@ for file in files.split():
py_compile.compile(filepath, $import_call(filepath$import_arg2), path)
else:
py_compile.compile(filepath, filepath + 'o', path)
-sys.stdout.write('\n')" 2>/dev/null || exit $?
+sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
# Local Variables:
# mode: shell-script
diff --git a/t/py-compile-files.sh b/t/py-compile-files.sh
new file mode 100644
index 000000000..fa2dd3251
--- /dev/null
+++ b/t/py-compile-files.sh
@@ -0,0 +1,36 @@
+#! /bin/sh
+# Copyright (C) 2022 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 <https://www.gnu.org/licenses/>.
+
+# Verify 'py-compile' script can handle inputs with spaces, etc...
+
+required=python
+. test-init.sh
+
+cp "$am_scriptdir/py-compile" . \
+ || fatal_ "failed to fetch auxiliary script py-compile"
+
+# Create files that require proper quoting.
+mkdir "dir with spaces"
+touch "nospace.py" "has space.py" "*.py" "dir with spaces/|.py"
+
+./py-compile "nospace.py" "has space.py" "*.py" "dir with spaces/|.py"
+
+py_installed "nospace.pyc"
+py_installed "has space.pyc"
+py_installed "*.pyc"
+py_installed "dir with spaces/|.pyc"
+
+:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [automake-commit] branch master updated: py-compile: handle filenames with whitespace,
Mike Frysinger <=