how to simulate tar filename substitution across piped subprocess.Popen() calls?

jkn jkn_gg at nicorp.f9.co.uk
Mon Nov 12 22:43:56 CET 2012


Hi Hans

[...]
>
> >         xargsproc.append("test -f %s/{} && md5sum %s/{}" % (mydir,
> > mydir))
>
> This will break if there are spaces in the file name, or other
> characters meaningful to the shell.  If you change if to
>
>         xargsproc.append("test -f '%s/{}' && md5sum '%s/{}'"
>                              % (mydir, mydir))
>
> , then it will only break if there are single quotes in the file name.

Fair point. As it happens, I know that there are no 'unhelpful'
characters in the filenames ... but it's still worth doing.

>
> As I understand, your plan is to rewrite this bit in pure Python, to
> get rid of any and all such problems.

Yep - as mentioned in another reply I wanted first to have something
which duplicated the current action (which has taken longer than I
expected), and then rework in a more pythonic way.

Still, I've learned some things about the subprocess module, and also
about the shell, so it's been far from wasted time.

    Regards
    Jon N


More information about the Python-list mailing list