From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: ian martins Newsgroups: gmane.emacs.devel Subject: Re: [elpa] externals/ob-haxe d10f2b1: ob-haxe.el: Escape special characters in shell commands Date: Sat, 30 Jan 2021 06:17:56 -0500 Message-ID: References: <20210129142001.29154.12046@vcs0.savannah.gnu.org> <20210129142002.527F320E7B@vcs0.savannah.gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9747"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jan 30 12:18:44 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1l5oH6-0002Rk-AT for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Jan 2021 12:18:44 +0100 Original-Received: from localhost ([::1]:46304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l5oH5-0005Ul-DC for ged-emacs-devel@m.gmane-mx.org; Sat, 30 Jan 2021 06:18:43 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48274) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l5oGY-00051A-Ph for emacs-devel@gnu.org; Sat, 30 Jan 2021 06:18:10 -0500 Original-Received: from mail-lj1-f180.google.com ([209.85.208.180]:41343) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1l5oGX-00046E-DQ for emacs-devel@gnu.org; Sat, 30 Jan 2021 06:18:10 -0500 Original-Received: by mail-lj1-f180.google.com with SMTP id y14so895869ljn.8 for ; Sat, 30 Jan 2021 03:18:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=3TH5FZegHzWW6VgolVcWbCj/cWgOAJbbH5Juur5akPo=; b=T+isx5EYafSectzGRp/JzK4dS4P23JHVbP3rA60U+imt08rGM8SffMPx14A4rFu7YT 7HC/8zKO4XF0I3D9IDTOKYVtAc6OcmYTbrCbkgoS8sfxUHT6EnKV4VzjTp+aBvbuWCzJ ss09AnJyB9BzYVsUOFkJA8CAh547OnjEn9QxsvwKEBrdVyPMBrkFaQaDM3b2gw5EpwqL OhnfvBf9r9e720SJCJZdVqMOrC8Vtv8Ruq13Fw2SyU4XWDzEUNMdLP26nkyU0N0sTvX8 clDsUVEdRU4xr/+aq2fR4xg1qGrj77eBsPLxKbbR7GOpZ6v4xgwI8qfX2hINqQ4IOzSG nOEw== X-Gm-Message-State: AOAM533mr+h8JhdT9IfWLFt2ihC77aKhNy7h6w6IgmtCtdk90g81ASGs Y4sVtX5XDJIrbMyxoXKRgnSXfxFzj16/cU2eIRU= X-Google-Smtp-Source: ABdhPJytpruFvNGHCEnPN/YxcMaZbFdIVO31wsO+VvuIjfLaX5hEgMxzgUtPEvC+UtUny/zzBUhAkkxkUVdnvo/s+QA= X-Received: by 2002:a05:651c:106b:: with SMTP id y11mr4870887ljm.28.1612005487610; Sat, 30 Jan 2021 03:18:07 -0800 (PST) In-Reply-To: Received-SPF: pass client-ip=209.85.208.180; envelope-from=ianxm1@gmail.com; helo=mail-lj1-f180.google.com X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:263605 Archived-At: > > +path to the executable, like \"/usr/local/bin/neko\". This is > > +run in a shell." > > I think it's not clear what "This is run in a shell" means here. > > Typically it either means that the usual "shell preprocessing" will take > place, so you can use $ spaces and quotes to construct a "chunk" of > a command, or it is just an implementation detail (in which case > there's no particular reason to mention it in such docstrings). It is the latter case. I wrote that before adding code to escape the string. It isn't useful anymore. I've removed it. > > @@ -126,11 +126,13 @@ replaced in this string.") > > (or (cdr (assq :haxe params)) > > org-babel-haxe-compiler)) > > (org-babel-neko-command > > - (or (cdr (assq :neko params)) > > - org-babel-neko-command)) > > + (replace-regexp-in-string "\\([ \"]\\)" "\\\\\\1" ; escape double quotes or spaces > > + (or (cdr (assq :neko params)) > > + org-babel-neko-command))) > > You might want to use `shell-quote-argument` instead, so it also escapes > backslashes, pipes, semi colons and whatnot and generally tries to > ensure that the strings is passed through "as is", so the user doesn't > need to know that the string is used as part of a shell command. Good suggestion. done. I've read a lot of the elisp docs but am unfamiliar with most of the builtin functions in emacs core. I should probably start from the assumption that whatever I want to do is in there somewhere and search before writing anything new.