emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Matt <matt@excalamus.com>
To: "Osher Jacob" <osherz5@gmail.com>
Cc: "emacs-orgmode" <emacs-orgmode@gnu.org>
Subject: Re: [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)]
Date: Mon, 16 Jan 2023 16:40:27 -0500	[thread overview]
Message-ID: <185bc86c826.11ae860d1190626.407710511075709301@excalamus.com> (raw)
In-Reply-To: <CAGsxwFZ88cybALCVGgma=5gENMhUa0Rk6xNkBNS_HdsmBgYe6w@mail.gmail.com>

Thank you for your report, Osher!

Windows shells aren't currently supported by ob-shell, AFAIK.  I'm open to including them.  Unfortunately, I don't have a Windows machine to test against.  

 ---- On Mon, 16 Jan 2023 11:27:52 -0500  Osher Jacob  wrote --- 
 > Expected behaviour:
 > On Windows, all lines of the babel shell block should be evaluated, with full output printed.

What's does `C-h v shell-file-name' say?  That should tell us what shell is being used.

 > #+begin_src shell
 >  echo 1
 >  echo 2
 >
 >
 > #+end_src
 >
 > #+RESULTS:
 > | Microsoft             | Windows   | [Version     | 10.0.19044.2364] |        |           |
 > | (c)                   | Microsoft | Corporation. | All              | rights | reserved. |
 > |                       |           |              |                  |        |           |
 > | c:\Users\osherj>echo  | 1         |              |                  |        |           |
 > | 1                     |           |              |                  |        |           |
 > |                       |           |              |                  |        |           |
 > | c:\Users\osherj>More? |           |              |                  |        |           |
 > 
 > The hacky way I solved it was to change this line:
 > (t (org-babel-eval shell-file-name (org-trim body))))))
 > to this:
 > (t (org-babel-eval shell-file-name (concat (org-trim body) "\n"))))))

I don't think org-trim is the issue.

Running the block (eventually) calls the default shell command, `org-babel--shell-command-on-region'.  This calls `org-babel--get-shell-file-name' on a temp file containing the block source using the "-c" flag.

I assume the shell used is cmdproxy.exe (https://git.savannah.gnu.org/cgit/emacs.git/tree/nt/cmdproxy.c).   It looks like this converts a "-c" to a "/c", among other things.

MSDN says for cmd.exe,

Parameter 	Description
/c 	Carries out the command specified by string and then stops.
/k 	Carries out the command specified by string and continues.

So, the way I reason it, ob-shell tries calling cmdproxy.exe using /c which basically calls cmd.exe /c, the block temp file is executed, and the shell stops.

I see that `org-babel--shell-command-on-region' calls `process-file' using the `shell-command-switch'.  It doesn't appear to be set anywhere else in `ob-eval' (see ob-eval:112).

> Let me know if there's any other information you need, or if I can help in any other way.

I wonder if changing `shell-command-switch' to "/k" would make a difference?  

That is, go through the steps to reproduce and before executing the block, run `M-: (setq shell-command-switch "/k")'.


  reply	other threads:[~2023-01-16 21:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-16 16:27 [BUG] ob-shell doesn't evaluate last line on Windows (cmd/cmdproxy) [9.6.1 ( @ c:/Users/Osher/AppData/Roaming/.emacs.d/elpa/org-9.6.1/)] Osher Jacob
2023-01-16 21:40 ` Matt [this message]
2023-01-17  1:07   ` Matt
2023-01-17 19:53     ` Osher Jacob
2023-01-18  5:09       ` Matt
2023-01-18  9:05         ` Ihor Radchenko
2023-01-19 16:28           ` Osher Jacob
2023-01-20  4:29             ` Matt
2023-01-20  9:27               ` Ihor Radchenko
2023-01-23  3:12                 ` Matt
2023-01-23 11:42                   ` Ihor Radchenko
2023-01-26  4:04                   ` Matt
2023-01-26  9:51                     ` Ihor Radchenko
2023-01-30  6:00                       ` Matt
2023-01-30 14:00                         ` Ihor Radchenko
2023-01-30 17:08                           ` Matt
2023-02-01 12:05                             ` Ihor Radchenko
2023-02-01 20:21                               ` Matt
2023-01-20  9:24             ` 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=185bc86c826.11ae860d1190626.407710511075709301@excalamus.com \
    --to=matt@excalamus.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=osherz5@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).