+2024-05-01 Collin Funk <collin.funk1@gmail.com>
+
+ gnulib-tool.py: Quote file names passed to 'patch'.
+ * pygnulib/GLTestDir.py (_patch_test_driver): Import shlex and cleanup
+ unused imports. Use shlex.quote() on the file names passed to 'patch'.
+ * pygnulib/GLFileSystem.py (GLFileSystem.lookup): Likewise. Perform
+ redirection using sp.call() arguments instead of using the shell.
+
2024-05-01 Bruno Haible <bruno@clisp.org>
readutmp, boot-time: Improve for some Cygwin installations.
#===============================================================================
import os
import re
+import sys
import filecmp
+import shlex
import subprocess as sp
from .constants import (
DIRS,
copyfile,
substart,
)
-from pygnulib.enums import CopyAction
+from .enums import CopyAction
from .GLError import GLError
from .GLConfig import GLConfig
copyfile(lookedupFile, tempFile)
ensure_writable(tempFile)
for diff_in_localdir in reversed(lookedupPatches):
- command = 'patch -s "%s" < "%s" >&2' % (tempFile, diff_in_localdir)
+ command = f'patch -s {shlex.quote(tempFile)} < {shlex.quote(diff_in_localdir)}'
try: # Try to apply patch
- sp.check_call(command, shell=True)
+ sp.check_call(command, shell=True, stdout=sys.stderr)
except sp.CalledProcessError as exc:
raise GLError(2, name) from exc
result = (tempFile, True)
import os
import re
import sys
+import shlex
import subprocess as sp
from pathlib import Path
from .constants import (
from .enums import CopyAction
from .GLError import GLError
from .GLConfig import GLConfig
-from .GLModuleSystem import GLModuleTable
-from .GLModuleSystem import GLModuleSystem
+from .GLModuleSystem import GLModuleTable, GLModuleSystem
from .GLFileSystem import GLFileSystem
-from .GLFileSystem import GLFileAssistant
from .GLMakefileTable import GLMakefileTable
from .GLEmiter import GLEmiter
from .GLFileTable import GLFileTable
print('patching file %s' % test_driver)
diffs = [ joinpath(DIRS['root'], name)
for name in [joinpath('build-aux', 'test-driver.diff'),
- joinpath('build-aux', 'test-driver-1.16.3.diff')]]
+ joinpath('build-aux', 'test-driver-1.16.3.diff')] ]
patched = False
for diff in diffs:
- command = f'patch {test_driver} < {diff}'
+ command = f'patch {shlex.quote(test_driver)} < {shlex.quote(diff)}'
try:
result = sp.call(command, shell=True, stdout=sp.DEVNULL, stderr=sp.DEVNULL)
except OSError as exc: