Collin Funk wrote:
> Ah, good point. I didn't realize it was possible to use a native
> Windows Python3 (os.name == 'nt') with Cygwin tools.

It appears that's what the original reporter is doing [1]: you see
file names with backslashes and you see Windows error codes being
reported, rather than POSIX error codes.

> What would be the proper way to invoke 'sh' there? For example this
> command in GLTestDir.py:
> 
>     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:
>         ...
> 
> Would the following be correct?
> 
>       command = ['sh', '-c', f'patch {shlex.quote(test_driver)} < 
> {shlex.quote(diff)}']
>       try:
>          result = sp.call(command, stdout=sp.DEVNULL, stderr=sp.DEVNULL)
>       except OSError as exc:
>          ...

Yes, this looks correct. But it needs to be conditionalized, so that we continue
to keep the simpler (and often also faster) code on Unix.

Bruno

[1] https://lists.gnu.org/archive/html/bug-gnulib/2024-04/msg00543.html




Reply via email to