Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

6 May, 2024: The networking issue during the past two days has been identified and appears to be fixed. Will keep monitoring.


devel / comp.lang.python / Re: Debugging automatic quotation in subprocess.Popen()

SubjectAuthor
o Re: Debugging automatic quotation in subprocess.Popen()Chris Angelico

1
Re: Debugging automatic quotation in subprocess.Popen()

<mailman.539.1665178090.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=19668&group=comp.lang.python#19668

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: ros...@gmail.com (Chris Angelico)
Newsgroups: comp.lang.python
Subject: Re: Debugging automatic quotation in subprocess.Popen()
Date: Sat, 8 Oct 2022 08:27:57 +1100
Lines: 27
Message-ID: <mailman.539.1665178090.20444.python-list@python.org>
References: <4MkMCn3lHnz9rxX@submission02.posteo.de>
<CAPTjJmp+ZhAdwvcsgzWgysvKdXsn01vX5SVRnXPCn7AsSssM8g@mail.gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: news.uni-berlin.de WTt2A+/GCRYe14pQxnTLIAxKuKILFIpfXhkAh7lKtXAw==
Return-Path: <rosuav@gmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=gmail.com header.i=@gmail.com header.b=laOh5iJQ;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.077
X-Spam-Evidence: '*H*': 0.85; '*S*': 0.00; '2022': 0.05; 'debug':
0.07; 'example:': 0.09; 'chrisa': 0.16; 'from:addr:rosuav': 0.16;
'from:name:chris angelico': 0.16; 'needed:': 0.16; 'work:': 0.16;
'wrote:': 0.16; 'python': 0.16; 'to:addr:python-list': 0.20;
'sat,': 0.22; 'command': 0.23; 'module': 0.31; 'message-
id:@mail.gmail.com': 0.32; 'there': 0.33; 'header:In-Reply-To:1':
0.34; 'received:google.com': 0.34; 'runs': 0.35;
'from:addr:gmail.com': 0.35; 'special': 0.37; 'received:209.85':
0.37; 'way': 0.38; 'received:209': 0.39; 'added': 0.39;
'received:209.85.208': 0.39; 'list': 0.39; 'something': 0.40;
'hello,': 0.40; 'want': 0.40; 'here.': 0.61; 'copy': 0.63;
'capable': 0.64; 'similar': 0.65; 'improve': 0.66; 'right': 0.68;
'subject:skip:s 10': 0.69; 'quote': 0.74; 'paste.': 0.84;
'quotes': 0.84
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:from:to:cc:subject:date:message-id:reply-to;
bh=3IORmwpSL0asz9CPpEMXvklMJrkE6Cnh4ApX7Kb3Rvc=;
b=laOh5iJQX4d/dsaDh8JMY7b/0tRTBl95LTzcn0wmEZIQsVUi+hVcYHuOms1P3ilLpj
wH0LDUp0eDZy9qfn3VkWGXhn6N1M2F0g10GV6p5v7ZI5L20JA5djRPH0xf4fB+VcdIfh
asHtmMMbguIjoZIHSOqQlj1yQnE12yfFk5OrDyBK3zEZDsRUdh9N2A3b1yKYWZlP97QG
UwFGmReNmuRrAIm6p2vgu8IZkJfUvqbhskhqa7yGbwpF8feDKPkR4qLUm5k+V85cGyqO
cBsgydoPLnVdwfFBA9unah3r9bxwByLndh5UiTd9idtog8Cj8ZEByUZh3Ff9uQK5L279
l6ew==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20210112;
h=to:subject:message-id:date:from:in-reply-to:references:mime-version
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
bh=3IORmwpSL0asz9CPpEMXvklMJrkE6Cnh4ApX7Kb3Rvc=;
b=6V7BlaVN13mJYCri4nmuq2NEsapCa23qMPf3F6GfqqYzZ2UYa8dngeg++Qg9GY5dm8
4sJ/S/HbTJXkR9KdFlc0zL0/kqBF2BsBlnumlBXocqr0Q9bFAjzDd4Okk1ENZ1bZ8VN0
xEYRww3IUqcgdydgnd2s3mfqN7yyN5wpVZidfwEfP+CE3ckEB5ccSoS18pqEaaWyUzKC
kpGDitKwQYfV1YHHyIkPDAd38VRyYiKA7jM67VizKiqf9yLrojEVGh2DVxOoJmAmRXkn
HKOI3rymJ0iGIKORaTD2Hf0uACY/VzvAOxg88c8vS7QYC6bO1gZijEJyiPgtkeyR0+gw
iS2A==
X-Gm-Message-State: ACrzQf1p5zbzVv6uiX3KHRVSCREle2jgXVr8j21XuSq6MYWbO7Te1JTK
zuvpwQF8/tucin4QqiDlx0GFzqACfCDdklUF9B8Mtc1f4UU=
X-Google-Smtp-Source: AMsMyM5WItrnfuUe132Ox65NlYXaM6HPPqpJ5z4iPsosqdtSW7mpNnPI4tLVV0Ga0U/YTe+dItCAvWo/5+nzhiTqwnk=
X-Received: by 2002:a05:6402:26d1:b0:459:bd2d:a88c with SMTP id
x17-20020a05640226d100b00459bd2da88cmr6474329edd.385.1665178088959; Fri, 07
Oct 2022 14:28:08 -0700 (PDT)
In-Reply-To: <4MkMCn3lHnz9rxX@submission02.posteo.de>
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <CAPTjJmp+ZhAdwvcsgzWgysvKdXsn01vX5SVRnXPCn7AsSssM8g@mail.gmail.com>
X-Mailman-Original-References: <4MkMCn3lHnz9rxX@submission02.posteo.de>
 by: Chris Angelico - Fri, 7 Oct 2022 21:27 UTC

On Sat, 8 Oct 2022 at 08:24, <c.buhtz@posteo.jp> wrote:
>
> Hello,
>
> I need to improve my understanding about how subprocess.Popen() does
> quote arguments. I have special case here.
>
> Simple example:
> Popen(['ls', '-l']) results on a shell in "ls -l" without quotation.
>
> Quotes are added if they are needed:
> Popen(['ls', 'folder with blank']) results on a shell in
> "ls 'folder with blank'".
>
> Am I right so far with the basics?
>
> Is there a way to be sure and to debug how Popen() give it to the shell?

That's kinda looking at it backwards; the shell first splits the
command into a list of arguments, and then runs it. Python has a
module that is capable of doing similar sorts of work:

https://docs.python.org/3/library/shlex.html

That may be helpful if you want to give the user something to copy and paste.

ChrisA

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor