From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id YEEfA8gxMmaUUAAA62LTzQ:P1 (envelope-from ) for ; Wed, 01 May 2024 14:12:56 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id YEEfA8gxMmaUUAAA62LTzQ (envelope-from ) for ; Wed, 01 May 2024 14:12:56 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; 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=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1714565575; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=uWThj4GCa+Yxda39v0IFEd8dnvs6as96q0MhJ4Pt58k=; b=R49cGj5wlj8Z0nyvEmuIcrIwwoiYbUvzlIUFtrbgeUBTbyv0Fr1kLYxCNda0VA9aw8pC/B HGPJ/bWTrwDqGKZWodzQo2c5eqWfl85+L1DXps9Q/TU4nBa2WsHl286+HUwAg1aPRSqV2N A2fk4tYg31xrJQ1EpJ2+TC2ae+LgdJfubNZ7WL/EzGJlZyqlTPiqGs+JlSZoE6bvW09qXp CFPmtA6oIdnXC9nmXpxxFxqdvHcnOUdzx11ImtwYhy5XlFiSRbrLhL6HXP62WNjUgC/vam 6Tpkeygt0ZcxzvWMRsP7SFwOAmjBKgl0jnaq55YgW/tzKJrSmDwxJhNBCcc8PQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; 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=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1714565575; a=rsa-sha256; cv=none; b=AV8URm48SoOZY3pexz/jKpZqE2kUNxkyTqmLkN0+RVViHSTXtOiwTVW/5yBBkQnRlAHL1i OJdyDAQsBtksud/7+2uGhWWRbx+0DnJFfPGMT3FF6OS1THRqfUk2v+2FVn+rqaQ1KIV5mV 3+XTD0Flqrw7pxb6MAOywQ1SXn8GmVuObuj4tXTi09qLwMwNv9KH4hjwGbN6TZkz56dK7S nOPNIT7RQWH9uYgadk5JtbcocMe0QOC/mvxVERWhZJCwF13vgrkbAz8ngHXXYjHg99X4Lq dZZUxuVG9i5TscN5BoEPwWOZJ7cT660s9BsX1/Z6TmgYKp4nQGsQQqGNRkiAnA== 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 D2DB2763F5 for ; Wed, 1 May 2024 14:12:55 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s28oY-0007rL-Ce; Wed, 01 May 2024 08:11:58 -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 1s28oM-0007pm-RC for emacs-orgmode@gnu.org; Wed, 01 May 2024 08:11:54 -0400 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s28oG-0005gr-QU for emacs-orgmode@gnu.org; Wed, 01 May 2024 08:11:43 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1s28oB-0004ma-4C for emacs-orgmode@gnu.org; Wed, 01 May 2024 14:11:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: [BUG] ob-shell: internal representation of cmdline arguments the same Date: Wed, 1 May 2024 19:11:30 +0700 Message-ID: References: <18f24e394a9.cf358fba4744433.3814984878900155603@excalamus.com> <87frv4cqa6.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla Thunderbird Content-Language: en-US, ru-RU In-Reply-To: <87frv4cqa6.fsf@localhost> Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -0.88 X-Migadu-Queue-Id: D2DB2763F5 X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -0.88 X-TUID: q0OQz0wGoZ3b On 29/04/2024 19:22, Ihor Radchenko wrote: > Matt writes: > >> #+begin_src bash :cmdline "1 2 3" [...] > To force quotes in the :cmdline one can do > > #+begin_src bash :cmdline "\"1 2 3\"" > echo "$1" > #+end_src I consider it as a kind of pitfall inconsistent with DWIM concept. An idea of a kludge is below. #+begin_src sh :cmdline "1 2 3" :results verbatim printf '%s\n' "$@" #+end_src #+RESULTS: : 1 2 3 #+begin_src sh :cmdline 1 2 3 :results verbatim printf '%s\n' "$@" #+end_src #+RESULTS: : 1 : 2 : 3 diff --git a/lisp/ob-core.el b/lisp/ob-core.el index 73fb70c26..efba97f2c 100644 --- a/lisp/ob-core.el +++ b/lisp/ob-core.el @@ -3363,7 +3363,7 @@ (defun org-babel-read (cell &optional inhibit-lisp-eval) ((save-match-data (and (string-match "^[[:space:]]*\"\\(.*\\)\"[[:space:]]*$" cell) (not (string-match "[^\\]\"" (match-string 1 cell))))) - (read cell)) + (propertize (read cell) 'org-babel-value 'quoted-string)) (t (org-no-properties cell)))) (defun org-babel--string-to-number (string) diff --git a/lisp/ob-shell.el b/lisp/ob-shell.el index 35d9e9376..77c3fe261 100644 --- a/lisp/ob-shell.el +++ b/lisp/ob-shell.el @@ -300,6 +300,9 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline) of the statements in BODY, if RESULT-TYPE equals `value' then return the value of the last statement in BODY." (let* ((shebang (cdr (assq :shebang params))) + (cmdline-quote + (and cmdline + (get-text-property 0 'org-babel-value cmdline) "\"")) (async (org-babel-comint-use-async params)) (results-params (cdr (assq :result-params params))) (value-is-exit-status @@ -329,7 +332,9 @@ (defun org-babel-sh-evaluate (session body &optional params stdin cmdline) nil (if shebang (when cmdline (list cmdline)) (list shell-command-switch - (concat (file-local-name script-file) " " cmdline))))) + (concat (file-local-name script-file) + " " cmdline-quote cmdline + cmdline-quote))))) (buffer-string)))) (session ; session evaluation (if async