Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:Windows': 0.02; 'scripts': 0.03; '(python': 0.07; 'linux,': 0.07; 'subject:PEP': 0.07; 'subject:support': 0.07; 'bash': 0.09; 'main()': 0.09; 'subject:using': 0.09; 'windows,': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'windows': 0.15; 'behaviour.': 0.16; 'command,': 0.16; 'failed!': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'grep': 0.16; 'scripts.': 0.16; 'subject: \n ': 0.16; 'subject:API': 0.16; 'world!': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'code.': 0.18; "skip:' 30": 0.19; 'thu,': 0.19; 'seems': 0.21; 'shell': 0.22; 'cc:addr:python.org': 0.22; "aren't": 0.24; 'instance,': 0.24; 'subject: .': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; '0);': 0.29; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; 'run': 0.32; 'maybe': 0.34; 'subject:from': 0.34; "can't": 0.35; 'skip:s 30': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; "didn't": 0.36; 'commands': 0.60; 'dave': 0.60; '2015': 0.84; 'fortunately': 0.84; 'pike': 0.84; 'subject:skip:F 10': 0.84; 'angel': 0.91; 'mistake': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=DLWOthECXPVsus6zKrvDfiJbimAE4QCNWYjR4j2FfgE=; b=GvnFJsb5cW7DWLh0kSUFz0QzpO0W2MX8rB7txLqtBcj6rridXyOMpiCaT0P0j/MRdA O7wTRPRw9mZoEQq5ZRrcCP9kKKOZZXA708tTpTkkIG89yt08Gdg2W8Bd7pJR4n9mgZQg JRFvB+ifKlF2iS6SCtil+YnAB3w7X4gSdUd3SqmXf2i3xMDPyOs7iGGuJ/U6g8BofVCW zhMfJ+zr3OsxzFIX49qpzuEu45N66QA3npJtKMXsnbnvJ75a7xE7oUADiVBMlo21o28C 22aG55CFmUGoXaer1SGT4F6ptEaEeungT9NNBNcLJXxO3lnrkrvuXNNVLsAEnItSIfWu vdZw== MIME-Version: 1.0 X-Received: by 10.107.16.32 with SMTP id y32mr2022704ioi.53.1430965186299; Wed, 06 May 2015 19:19:46 -0700 (PDT) In-Reply-To: <554AB8A5.708@davea.name> References: <554AB8A5.708@davea.name> Date: Thu, 7 May 2015 12:19:46 +1000 Subject: Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430965194 news.xs4all.nl 2903 [2001:888:2000:d::a6]:36147 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90085 On Thu, May 7, 2015 at 10:58 AM, Dave Angel wrote: > There's nothing Windows-specific about that behaviour. In Linux, there are > bash commands that can only be run by using shell=True. Fortunately Popen > didn't make the mistake of pretending it's a shell. But bash commands aren't the same as shell scripts. For instance, if you want to enumerate bash aliases, you can't exec() to the 'alias' command, because there isn't one. But shell scripts *can* be exec'd: $ grep $ exec_demo.* exec_demo.c:#include exec_demo.c:#include exec_demo.c:int main() exec_demo.c:{ exec_demo.c: printf("This part is coming from C code.\n"); exec_demo.c: int err=execl("./exec_demo.sh", 0); exec_demo.c: printf("exec() failed! %d\n",err); exec_demo.c:} exec_demo.sh:#!/bin/sh exec_demo.sh:echo This part ran from the shell. exec_demo.sh:echo Hello, world! $ ./a.out This part is coming from C code. This part ran from the shell. Hello, world! $ pike -e 'Process.exec("./exec_demo.sh");' This part ran from the shell. Hello, world! $ python -c 'import subprocess; subprocess.call(["./exec_demo.sh"])' This part ran from the shell. Hello, world! (Python doesn't seem to have any way to 'exec', but a subprocess comes to the same thing.) I don't know about Windows, but it seems reasonable to be able to be able to run many types of program equally, including batch files. But maybe Windows is just weak that way. ChrisA