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 jweese
Recipients jweese, nik-sm
Date 2020-02-20.17:39:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1582220385.13.0.0723106966125.issue39692@roundup.psfhosted.org>
In-reply-to
Content
> it seems strange/wrong to invoke an executable via "bash -c executable arg1 arg2", rather than just "executable arg1 arg2"!

I agree it's strange to invoke a single executable that way, but remember that -c allows a string of arbitrary bash code. (It just happens that bash code that consists of a single executable calls it -- useful behavior in a shell.)

Consider:

$ bash -c 'f() { printf "%s\n" "$@"; }; f "$@"' - foo bar baz
foo
bar
baz

> 1) If there exist use cases for setting `shell=True` and doing "bash -c my_executable arg2 arg3", then the documentation should say something like the following:
> """
> Using `shell=True` invokes the sequence of args via `bash -c`. In this case, the first argument MUST be an executable, and the subsequent arguments will be stored as bash parameters for that executable (`$0`, `$1`, etc).
> """

I'd be okay with clearer docs, but the given language is not quite right. For example, the actual shell call is /bin/sh (and depends on the platform). And, as described above, I think it would be too restrictive to say the first argument must be a single executable.

On the other hand, I disagree with option 2. I think raising an error would be very restrictive, and secretly quoting the argument could be surprising for (the few) people who understand the underlying shell mechanism.
History
Date User Action Args
2020-02-20 17:39:45jweesesetrecipients: + jweese, nik-sm
2020-02-20 17:39:45jweesesetmessageid: <1582220385.13.0.0723106966125.issue39692@roundup.psfhosted.org>
2020-02-20 17:39:45jweeselinkissue39692 messages
2020-02-20 17:39:44jweesecreate