<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
On 07.01.2018 22:32, Christian Tismer wrote:<br>
<blockquote type="cite"
cite="mid:504650b4-3217-8aa4-91a6-d3de9719b9b3@stackless.com">
<pre wrap="">Hi Chris,
On 07.01.18 18:18, Chris Angelico wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Redirecting this part of the conversation to python-ideas.
On Mon, Jan 8, 2018 at 3:17 AM, Christian Tismer <a class="moz-txt-link-rfc2396E" href="mailto:tismer@stackless.com"><tismer@stackless.com></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">As a side note: In most cases where shell=True is found, people
seem to need evaluation of the PATH variable. To my understanding,
</pre>
<blockquote type="cite">
<blockquote type="cite">
<blockquote type="cite">
<pre wrap="">from subprocess import call
call(("ls",))
</pre>
</blockquote>
</blockquote>
</blockquote>
<pre wrap="">
works in Linux, but (with dir) not in Windows. But that is misleading
because "dir" is a builtin command but "ls" is not. The same holds for
"del" (Windows) and "rm" (Linux).
</pre>
</blockquote>
<pre wrap="">
That's exactly what shell=True is for - if you want a shell feature,
you use the shell. What exactly would emulate_shell do? Would it
simply do a $PATH or %PATH% search, but otherwise function as
shell=False? Would it process redirection? Would it handle
interpolations? I think not, from your description:
</pre>
<blockquote type="cite">
<pre wrap="">Perhaps it would be a good thing to emulate the builtin programs
in python by some shell=True replacement (emulate_shell=True?)
to match the normal user expectations without using the shell?
</pre>
</blockquote>
<pre wrap="">
but it becomes difficult to draw the line. For instance, with
emulate_shell=True, what would you do with all the sh/bash built-ins:
<a class="moz-txt-link-freetext" href="https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html">https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html</a>
<a class="moz-txt-link-freetext" href="https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html">https://www.gnu.org/software/bash/manual/html_node/Bash-Builtins.html</a>
I'm thinking especially of the commands where bash has its own
handling of something that could otherwise be found in $PATH, like
pwd, time, and echo, but shells can do a lot of other things too.
When do you actually want to execute a shell built-in from Python but
without using the shell itself? You give the example of ls/dir, but if
that ever comes up in real-world code, I'd toss it out and recommend a
cross-platform os.listdir or equivalent. There are plenty of times
I've wanted a really quick way to redirect a standard stream from
Python, but that isn't part of what you're recommending. Can you give
a real-world example that would be improved by this?
I know this was just a side note in your original, but I'd like to
hear more about what would make it useful.
</pre>
</blockquote>
<pre wrap="">
No, I cannot. I just thought of a way to keep users from using
"shell=True". I *think* they do it after they experience that
"del" for instance is not found. They conclude "ah, I need the
shell", which is not true.</pre>
</blockquote>
Even putting aside the fact this is pure conjecture, the kind of
people who make decisions like this will find a zillion more ways to
shoot themselves in the foot. They don't need a cleaner syntax, they
need to learn the basics of programming in a high-level language to
understand how it's different from programming in the shell. In
particular, why spawning a subprocess for something covered by a
library function is a bad idea.<br>
<blockquote type="cite"
cite="mid:504650b4-3217-8aa4-91a6-d3de9719b9b3@stackless.com">
<pre wrap="">
So whatever you come up with, the effect should be that people
no longer use the shell. THATs what I want, after bad experience with
non-escaped "^" in a regex, that caused some really weird result.
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Python-ideas mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Python-ideas@python.org">Python-ideas@python.org</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/python-ideas">https://mail.python.org/mailman/listinfo/python-ideas</a>
Code of Conduct: <a class="moz-txt-link-freetext" href="http://python.org/psf/codeofconduct/">http://python.org/psf/codeofconduct/</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Regards,
Ivan</pre>
</body>
</html>