all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* org-babel shell in windows not finishing command
@ 2022-12-12  8:17 Vlastimil Vondra
  2022-12-12 12:39 ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Vlastimil Vondra @ 2022-12-12  8:17 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

Hello,

I'm trying to run some shell block code (in windows they should evaluate in
cmd). But when executing org-babel block code, it seems that org-babel is
not finishing the last command. If I run:

#+begin_src shell :results output
  echo %cd%
  echo "hello"
#+end_src

then the output is

#+RESULTS:
: Microsoft Windows [Version 10.0.19045.2251]
: (c) Microsoft Corporation. All rights reserved.
:
: c:\Users\johndoe\Org>echo %cd%
: c:\Users\johndoe\Org
:
: c:\Users\johndoe\Org>More?

More? means cmd is expecting some additional command (creating multiline
statemens). In cmd typying either ( or ^ result in More?, but I don't know
what is causing this error in org-babel. Interestingly, if run like this:

#+begin_src shell :results output :session shell
  echo "%cd%"
  echo "hello"
#+end_src

I'm getting the right output:

#+RESULTS:
: Microsoft Windows [Version 10.0.19045.2251]
: (c) Microsoft Corporation. All rights reserved.
: echo "%cd%"
: "c:\Users\johndoe\Org"
: echo "hello"
: "hello"

But only when run for the first time, if running for second time, I'm
getting this:

#+RESULTS:
:
: cd%"
: "c:\Users\johndoe\Org"
: echo "hello"
: "hello"

Any way how to fix it either with :session shell command or without?
Best regards,
Vlastimil Vondra

[-- Attachment #2: Type: text/html, Size: 2984 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-12  8:17 org-babel shell in windows not finishing command Vlastimil Vondra
@ 2022-12-12 12:39 ` Ihor Radchenko
  2022-12-12 13:07   ` Vlastimil Vondra
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-12-12 12:39 UTC (permalink / raw)
  To: Vlastimil Vondra; +Cc: emacs-orgmode

Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:

> I'm trying to run some shell block code (in windows they should evaluate in
> cmd). But when executing org-babel block code, it seems that org-babel is
> not finishing the last command.

What is your Org version and Emacs version? (the output of
M-x org-version and M-x emacs-version).

-- 
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>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-12 12:39 ` Ihor Radchenko
@ 2022-12-12 13:07   ` Vlastimil Vondra
  2022-12-12 13:10     ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Vlastimil Vondra @ 2022-12-12 13:07 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 797 bytes --]

 Hi Ihor,
Org mode version 9.5.5
GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) of 2022-09-13

Best regards,
Vlastimil Vondra

On Mon, 12 Dec 2022 at 13:39, Ihor Radchenko <yantar92@posteo.net> wrote:

> Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:
>
> > I'm trying to run some shell block code (in windows they should evaluate
> in
> > cmd). But when executing org-babel block code, it seems that org-babel is
> > not finishing the last command.
>
> What is your Org version and Emacs version? (the output of
> M-x org-version and M-x emacs-version).
>
> --
> 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>
>

[-- Attachment #2: Type: text/html, Size: 1521 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-12 13:07   ` Vlastimil Vondra
@ 2022-12-12 13:10     ` Ihor Radchenko
  2022-12-12 15:28       ` Vlastimil Vondra
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-12-12 13:10 UTC (permalink / raw)
  To: Vlastimil Vondra; +Cc: emacs-orgmode

Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:

> Org mode version 9.5.5
> GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) of 2022-09-13

We have made a number of fixes in this area in Org 9.6.
Please upgrade and let us know if you are still seeing the problem.

-- 
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>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-12 13:10     ` Ihor Radchenko
@ 2022-12-12 15:28       ` Vlastimil Vondra
  2022-12-13  7:45         ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Vlastimil Vondra @ 2022-12-12 15:28 UTC (permalink / raw)
  To: Ihor Radchenko; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

Hi,
after upgrading to 9.6. The output is exactly the same.

V.

On Mon, 12 Dec 2022 at 14:10, Ihor Radchenko <yantar92@posteo.net> wrote:

> Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:
>
> > Org mode version 9.5.5
> > GNU Emacs 28.2 (build 2, x86_64-w64-mingw32) of 2022-09-13
>
> We have made a number of fixes in this area in Org 9.6.
> Please upgrade and let us know if you are still seeing the problem.
>
> --
> 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>
>

[-- Attachment #2: Type: text/html, Size: 1351 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-12 15:28       ` Vlastimil Vondra
@ 2022-12-13  7:45         ` Ihor Radchenko
  2024-05-20 18:37           ` Ihor Radchenko
  0 siblings, 1 reply; 10+ messages in thread
From: Ihor Radchenko @ 2022-12-13  7:45 UTC (permalink / raw)
  To: Vlastimil Vondra; +Cc: emacs-orgmode

Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:

> after upgrading to 9.6. The output is exactly the same.

It would be great if someone with access to Windows could debug this.

First, the version without session. It should be slightly less tricky -
Org creates a temporary script file and executes it.

-- 
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>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2022-12-13  7:45         ` Ihor Radchenko
@ 2024-05-20 18:37           ` Ihor Radchenko
  2024-05-20 19:39             ` Ihor Radchenko
  2024-05-21 10:34             ` Max Nikulin
  0 siblings, 2 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-20 18:37 UTC (permalink / raw)
  To: Vlastimil Vondra, Matt; +Cc: emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> Vlastimil Vondra <vlastimil.vondra@gmail.com> writes:
>
>> after upgrading to 9.6. The output is exactly the same.
>
> It would be great if someone with access to Windows could debug this.

No takers, so I went ahead with installing virtual machine.

Confirmed.

The culprit is the fact that org-babel-eval uses process-file and on
Windows cmdproxy.exe provided by emacs has this weird behaviour with
outputting all the below when piped in script text:

In powershell,

echo 'echo foo' | cmdproxy.exe yields

: Microsoft Windows [Version 10.0.19045.2251]
: (c) Microsoft Corporation. All rights reserved.
:
: c:\Users\johndoe\Org>echo foo
: foo

In contrast, cmdproxy.exe -c 'echo foo' outputs

: foo

This looks like Emacs bug, because the same problem with all that
boilerplate text happens when using shell-command-on-region.

I reported it as
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71081

Let's see what Emacs devs say.

-- 
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>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2024-05-20 18:37           ` Ihor Radchenko
@ 2024-05-20 19:39             ` Ihor Radchenko
  2024-05-21 10:34             ` Max Nikulin
  1 sibling, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-20 19:39 UTC (permalink / raw)
  To: Vlastimil Vondra; +Cc: Matt, emacs-orgmode

Ihor Radchenko <yantar92@posteo.net> writes:

> This looks like Emacs bug, because the same problem with all that
> boilerplate text happens when using shell-command-on-region.
>
> I reported it as
> https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71081
>
> Let's see what Emacs devs say.

... and they say that it is not Emacs bug. Just cmd.exe cannot be used
this way (piping input to it).

So, no `process-file' on Windows. We must either dump the script into
.bat file or pass it via -c '....' switch. Or maybe just remove the
boilerplate via regexp (heuristics).

I think that our current code for :shebang will not work either on
Windows.

Bottom line - Windows does not follow POSIX and does all kinds of weird
staff. Oh well.
Unimportant.

For :session, the situation is similar - there is simply no easy way to
distinguish actual command output and the boilerplate spat by
cmd.exe. Maybe we can create a workaround removing the boilerplate via
regexp. That's probably the easiest.

Whoever is familiar with Windows, feel free to work on a fix.
We probably need a whole separate branch of logic just for Windows in
`org-babel-eval' and ob-shell.

-- 
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>


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2024-05-20 18:37           ` Ihor Radchenko
  2024-05-20 19:39             ` Ihor Radchenko
@ 2024-05-21 10:34             ` Max Nikulin
  2024-05-21 10:39               ` Ihor Radchenko
  1 sibling, 1 reply; 10+ messages in thread
From: Max Nikulin @ 2024-05-21 10:34 UTC (permalink / raw)
  To: emacs-orgmode

On 21/05/2024 01:37, Ihor Radchenko wrote:
> echo 'echo foo' | cmdproxy.exe yields
> 
> : Microsoft Windows [Version 10.0.19045.2251]
> : (c) Microsoft Corporation. All rights reserved.
> :
> : c:\Users\johndoe\Org>echo foo
> : foo

Out of curiosity, does the /q option help to suppress the banner?



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: org-babel shell in windows not finishing command
  2024-05-21 10:34             ` Max Nikulin
@ 2024-05-21 10:39               ` Ihor Radchenko
  0 siblings, 0 replies; 10+ messages in thread
From: Ihor Radchenko @ 2024-05-21 10:39 UTC (permalink / raw)
  To: Max Nikulin; +Cc: emacs-orgmode

Max Nikulin <manikulin@gmail.com> writes:

> On 21/05/2024 01:37, Ihor Radchenko wrote:
>> echo 'echo foo' | cmdproxy.exe yields
>> 
>> : Microsoft Windows [Version 10.0.19045.2251]
>> : (c) Microsoft Corporation. All rights reserved.
>> :
>> : c:\Users\johndoe\Org>echo foo
>> : foo
>
> Out of curiosity, does the /q option help to suppress the banner?

No.


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-05-21 10:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-12  8:17 org-babel shell in windows not finishing command Vlastimil Vondra
2022-12-12 12:39 ` Ihor Radchenko
2022-12-12 13:07   ` Vlastimil Vondra
2022-12-12 13:10     ` Ihor Radchenko
2022-12-12 15:28       ` Vlastimil Vondra
2022-12-13  7:45         ` Ihor Radchenko
2024-05-20 18:37           ` Ihor Radchenko
2024-05-20 19:39             ` Ihor Radchenko
2024-05-21 10:34             ` Max Nikulin
2024-05-21 10:39               ` Ihor Radchenko

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.