From: Max Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline
Date: Wed, 24 Apr 2024 17:33:37 +0700 [thread overview]
Message-ID: <v0an63$3n2$1@ciao.gmane.io> (raw)
In-Reply-To: <878r14qso9.fsf@localhost>
On 23/04/2024 17:28, Ihor Radchenko wrote:
>
> I propose the attached patch.
> +++ 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))))
Using `shell-command-switch' unconditionally may lead to executing
/bin/sh instead of shell specified by `shell-file-name' for script files
having no shebang, see
https://superuser.com/questions/502984/writing-shell-scripts-that-will-run-on-any-shell-using-multiple-shebang-lines
> The kernel refuses to execute such scripts and returns ENOEXEC, so the
> exact behavior depends on the program you run such a script /from/.
>
> - bash 4.2.39 -- uses itself
> - busybox-ash 1.20.2 -- uses itself
> - dash 0.5.7 -- runs /bin/sh
> - fish 1.23.1 -- complains about ENOEXEC, then blames the wrong file
> - AT&T ksh 93u+2012.08.01 -- uses itself
> - mksh R40f -- runs /bin/sh
> - pdksh 5.2.14 -- runs /bin/sh
> - sh-heirloom 050706 -- uses itself
> - tcsh 6.18.01 -- runs /bin/sh
> - zsh 5.0.0 -- runs /bin/sh
> - cmd.exe 5.1.2600 -- looks at you funny
I am not going to spend time testing current versions.
I believe, multiple arguments should be specified as '(1 a "b c").
With shebang (as header arg or as part of the body) command should be
/path/to/script [ARGUMENT]...
when there is no shebang
/shell/executable /path/to/script [ARGUMENT]...
next prev parent reply other threads:[~2024-04-24 10:34 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-18 15:54 [BUG] ob-shell: :shebang changes interpretation of :cmdline Max Nikulin
2023-11-18 18:09 ` Matt
2023-12-04 13:58 ` Ihor Radchenko
2023-12-04 20:41 ` Matt
2023-11-18 18:20 ` [BUG] ob-shell: :cmdline fails with single argument (was Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline) Matt
2023-11-19 6:57 ` Max Nikulin
2023-11-19 7:57 ` Matt
2024-04-21 15:09 ` [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline Matt
2024-04-23 10:28 ` Ihor Radchenko
2024-04-24 10:33 ` Max Nikulin [this message]
2024-04-24 12:52 ` Ihor Radchenko
2024-04-25 10:06 ` Max Nikulin
2024-04-26 11:49 ` Ihor Radchenko
2024-04-27 10:31 ` Max Nikulin
2024-04-27 13:37 ` Max Nikulin
2024-04-28 12:34 ` Ihor Radchenko
2024-06-27 12:47 ` Ihor Radchenko
2024-06-27 13:00 ` [BUG] ob-shell may use /bin/sh instead of the specified shell when :cmdline is provided (was: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline) Ihor Radchenko
2024-06-27 13:08 ` Ihor Radchenko
2024-04-23 10:51 ` [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline Max Nikulin
2024-04-23 17:08 ` Max Nikulin
2024-04-26 13:09 ` [DISCUSSION] The meaning of :cmdline header argument across babel backends (was: [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline) Ihor Radchenko
2024-04-27 10:53 ` [DISCUSSION] The meaning of :cmdline header argument across babel backends Max Nikulin
2024-04-29 13:33 ` Ihor Radchenko
2024-05-01 17:48 ` Matt
2024-05-01 18:01 ` Ihor Radchenko
2024-05-02 18:50 ` Matt
2024-05-03 12:12 ` Ihor Radchenko
2024-05-20 18:01 ` Matt
2024-05-21 10:28 ` Max Nikulin
2024-05-21 11:34 ` Ihor Radchenko
2024-06-27 14:57 ` Ihor Radchenko
2024-04-26 13:12 ` [PATCH] Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline Ihor Radchenko
2024-04-27 7:43 ` Matt
2024-04-27 7:48 ` Ihor Radchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='v0an63$3n2$1@ciao.gmane.io' \
--to=manikulin@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).