From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id oNAKNGCNJ2Y/cAAAe85BDQ:P1 (envelope-from ) for ; Tue, 23 Apr 2024 12:28:49 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id oNAKNGCNJ2Y/cAAAe85BDQ (envelope-from ) for ; Tue, 23 Apr 2024 12:28:48 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=q4MENNIA; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713868128; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=yzXJp74lCN3NxtLTZUK9MBcAgIofGsAOvaHSPl2Xc9k=; b=YJ9xfg13tHQdpleqWgpliZvvssSIMGaOAsHYhGSyV6qTQJaOG0DjfDymO5yK643L9iPWsQ KodsvRzxuHEhJxybZ7vO6NQw28uSzf/goIpX0bHt3w5TBbjneHnaiP49JmbRBqAEmhkUO3 5DF0s3idP+0Elx+G5y7qFb604gHt5ncVex73hNERfge5zf2uhgvBVEKLFJeVF7hSKvcrxL SxbCaSUt+fP49Ulr0XSaR0l4zBdevGr2KpxarNBo8d7tmwZAuwtnLHjTMbCPfnDgWqo3HB QN7c/ZeMIj1ebeBv2WNDzhxXbnA0UbkwuKXtOSbUIEKymDklgdx2JsSpU6xrrw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713868128; a=rsa-sha256; cv=none; b=aSa08ZPgS8tnZ9E7JiXgLo50gLEYLZ80kA4pXp7gaOmYWHeVHpGhP9Icj0U9nx85pCCVTn 1Xj4fsf1s2sdywxD+LNpt4nXzfPRaoDn0ZoeB3IwODUosso3Sf+O9hcip940ZO0gWQFPYW W3P99IMYXWUhw1jXZiUTPnOqpkbfUfQEvsmh8uusZHFnhDQFqIff1oEY/oYUQKIJeCY9x6 JkfmyGHZIoRMDHz9GiAdIbBjbRgCO8e5rQnMa2H3lc/0SPzJGAB1Clya3gcBuKCSD5YiYF nYWEay3CgBQSqaFCN+fSGOf/x5B0y6MZ06JGbJntpuoud4XUYKwgnbTvdAGXng== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=q4MENNIA; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6F8AC25A39 for ; Tue, 23 Apr 2024 12:28:48 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzDNT-00078O-IK; Tue, 23 Apr 2024 06:27:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzDNR-000783-OS for emacs-orgmode@gnu.org; Tue, 23 Apr 2024 06:27:54 -0400 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzDNP-0001rI-3P for emacs-orgmode@gnu.org; Tue, 23 Apr 2024 06:27:53 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id D490B240104 for ; Tue, 23 Apr 2024 12:27:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1713868067; bh=gfy+fZE/uryND0K1ml/01DTINXzTNkOYqQ/FsNEYLq4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=q4MENNIAv0GCv4OkH98U/Yf+CMC115CckB1V5oefbFG0CU8AhrnHKdX3bYZI7Djth kk7DFQFcfHQy6nDbrgI1e/3AWeWqOvbieffhn5NjkgQwS1ddCxB5CD51LqUTaNGXK9 xjqQaSY+o1lwHU9Wc3AGRfkhZljdFUH+yXZbfh59OWFTTqEZ6Obiu69vqCpD6J4kcR sN/HyPuoKDEyavJN60C+fQvjc5TYlLtDFwkhZBM0NfLCeVWMaR2Mb6TzCRiRWHih4J kySJot4kROQlHdKwOivZK9cIIbQ9a9AhqXxeiy7mcstEsxLgfap5lUTqy05dacxoDZ 2TWK9XAvRoUdQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VNyxG5Twvz9rxW; Tue, 23 Apr 2024 12:27:46 +0200 (CEST) From: Ihor Radchenko To: Matt Cc: Max Nikulin , emacs-orgmode Subject: Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline In-Reply-To: <18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com> References: <18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com> Date: Tue, 23 Apr 2024 10:28:38 +0000 Message-ID: <878r14qso9.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -7.59 X-Spam-Score: -7.59 X-Migadu-Queue-Id: 6F8AC25A39 X-Migadu-Scanner: mx12.migadu.com X-TUID: U7gvtR08o4Fi --=-=-= Content-Type: text/plain Matt writes: > Whether this is a solution, in part, depends on the perennial problem of shell blocks: knowing what's wrong means knowing what's right. > > The proposed solution assumes we intend to parse the characters following :cmdline as space delimited and grouped by quotes. However, AFAICT, the parsing issue makes this solution ambiguous. > > Thoughts? Manually parsing the shell arguments is calling for trouble. Especially when the arguments involve shell-specific escapes like :cmdline 1\ 2\ 3 Since escape characters may vary from shell to shell, it is not a good idea to parse the arguments on Elisp side. We should better leave this job to the shell. I propose the attached patch. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ob-shell-Pass-cmdline-arguments-consistently-regardl.patch >From e0cf4161b4af05c513ba402ee9625851853c9465 Mon Sep 17 00:00:00 2001 Message-ID: From: Ihor Radchenko Date: Tue, 23 Apr 2024 13:22:22 +0300 Subject: [PATCH] ob-shell: Pass :cmdline arguments consistently regardless of :shebang * lisp/ob-shell.el (org-babel-sh-evaluate): When invoking script file generated from the code block, consistently use -c command line, even when :shebang is header argument is provided. The previous approach with call caused differences in how shell parsed the provided command line arguments. Reported-by: Max Nikulin Link: https://orgmode.org/list/18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com --- lisp/ob-shell.el | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index 35d9e9376..30b3ea322 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -322,14 +322,12 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline) (with-temp-buffer (with-connection-local-variables (apply #'process-file - (if shebang (file-local-name script-file) - shell-file-name) + shell-file-name stdin-file (current-buffer) nil - (if shebang (when cmdline (list cmdline)) - (list shell-command-switch - (concat (file-local-name script-file) " " cmdline))))) + (list shell-command-switch + (concat (file-local-name script-file) " " cmdline)))) (buffer-string)))) (session ; session evaluation (if async -- 2.44.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--