This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients alex, cvrebert, eric.araujo, ncoghlan, pitrou
Date 2011-10-22.01:10:22
SpamBayes Score 0.026233213
Marked as misclassified No
Message-id <1319245822.94.0.219383408739.issue13238@psf.upfronthosting.co.za>
In-reply-to
Content
That's a fair point, but I think it actually *improves* the argument for better helper functions, since we can have them automatically invoke shlex.quote() on all of the arguments:

    def _shell_format(cmd, args, kwds):
        args = map(shlex.quote, args)
        kwds = {k:shlex.quote(v) for k, v in kwds}
        return cmd.format(*args, **kwds)

    def _invoke_shell(func, cmd, args, kwds):
        return func(_shell_format(cmd, args, kwds), shell=True)

    def format_shell_call(cmd, *args, kwds):
        return _shell_format(cmd, args, kwds)

    def shell_call(cmd, *args, **kwds):
        return _invoke_shell(subprocess.call, cmds, args, kwds)

    def check_shell_call(cmd, *args, **kwds):
        return _invoke_shell(subprocess.check_call, cmds, args, kwds)

    def check_shell_output(cmd, *args, **kwds):
        return _invoke_shell(subprocess.check_output, cmds, args, kwds)
History
Date User Action Args
2011-10-22 01:10:23ncoghlansetrecipients: + ncoghlan, pitrou, eric.araujo, alex, cvrebert
2011-10-22 01:10:22ncoghlansetmessageid: <1319245822.94.0.219383408739.issue13238@psf.upfronthosting.co.za>
2011-10-22 01:10:22ncoghlanlinkissue13238 messages
2011-10-22 01:10:22ncoghlancreate