From: Matt <matt@excalamus.com>
To: "Max Nikulin" <manikulin@gmail.com>
Cc: "emacs-orgmode" <emacs-orgmode@gnu.org>
Subject: [BUG] ob-shell: :cmdline fails with single argument (was Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline)
Date: Sat, 18 Nov 2023 19:20:47 +0100 [thread overview]
Message-ID: <18be3a9f244.11331358a3423956.2826184920394948569@excalamus.com> (raw)
In-Reply-To: <ujamo1$5t9$1@ciao.gmane.io>
[-- Attachment #1: Type: text/plain, Size: 951 bytes --]
---- On Sat, 18 Nov 2023 16:54:39 +0100 Max Nikulin wrote ---
> I have faced an inconsistency with :cmdline treatment in ob-shell.el.
These are sadly easy to find.
If you run:
#+begin_src bash :cmdline 1
echo "$1"
#+end_src
Then it fails with
list: Wrong type argument: sequencep, 1
However, running this works:
#+begin_src bash :cmdline "1"
echo "$1"
#+end_src
I didn't dig too much into it, but it looks like :cmdline expects a sequence. When multiple arguments are passed, such as :cmdline 1 2 3, then "1 2 3" is passed into process-file. (sequencep "1 2 3") is t. (sequencep 1) is nil. So, to work around this a single :cmdline argument must be surrounded by quotes to make it a sequence. (sequencep "1") is t. Obviously, this should be fixed.
Attached is a patch to test for this whenever we're ready to tackle making execution mutually consistent. I'm still reviewing the library and am not quite ready for that yet.
[-- Attachment #2: test-cmdline-with-single-argument-shouldnt-require-quotes.patch --]
[-- Type: application/octet-stream, Size: 861 bytes --]
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index 879555af0..d41387e57 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -436,6 +436,19 @@ exiting with a non-zero return code multiple times."
(buffer-string)))))
(kill-buffer "*Org-Babel Error Output*")))
+(ert-deftest test-cmdline-with-single-argument-shouldnt-require-quotes ()
+ "The original implementation of :cmdline required a single element
+to be surrounded by goes to work."
+ (should
+ (equal 1
+ (org-test-with-temp-text
+ ;; "#+begin_src sh :cmdline \"1\" :shebang #!/bin/bash
+ "#+begin_src sh :cmdline 1 #!/bin/bash
+echo \"$1\"
+<point>
+#+end_src"
+ (org-babel-execute-src-block)))))
+
(provide 'test-ob-shell)
;;; test-ob-shell.el ends here
next prev parent reply other threads:[~2023-11-18 18:21 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 ` Matt [this message]
2023-11-19 6:57 ` [BUG] ob-shell: :cmdline fails with single argument (was Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline) 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
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=18be3a9f244.11331358a3423956.2826184920394948569@excalamus.com \
--to=matt@excalamus.com \
--cc=emacs-orgmode@gnu.org \
--cc=manikulin@gmail.com \
/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).