[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdl
From: |
Ihor Radchenko |
Subject: |
Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline |
Date: |
Tue, 23 Apr 2024 10:28:38 +0000 |
Matt <matt@excalamus.com> 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.
>From e0cf4161b4af05c513ba402ee9625851853c9465 Mon Sep 17 00:00:00 2001
Message-ID:
<e0cf4161b4af05c513ba402ee9625851853c9465.1713867979.git.yantar92@posteo.net>
From: Ihor Radchenko <yantar92@posteo.net>
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
<shell-name> -c <script-file> <cmdline-args> command line, even when
:shebang is header argument is provided. The previous approach with
<script-file> <cmdline-args> call caused differences in how shell
parsed the provided command line arguments.
Reported-by: Max Nikulin <manikulin@gmail.com>
Link:
18f01342a2f.124ad27612732529.8693431365849276517@excalamus.com">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
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
- [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Matt, 2024/04/21
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline,
Ihor Radchenko <=
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Max Nikulin, 2024/04/24
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Ihor Radchenko, 2024/04/24
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Max Nikulin, 2024/04/25
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Ihor Radchenko, 2024/04/26
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Max Nikulin, 2024/04/27
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Max Nikulin, 2024/04/27
- Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Ihor Radchenko, 2024/04/28
Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline, Max Nikulin, 2024/04/23