unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Problems with call-process (= identifying run-python issues)
@ 2020-08-18 13:36 Juan José García-Ripoll
  2020-08-18 15:41 ` Eli Zaretskii
  0 siblings, 1 reply; 8+ messages in thread
From: Juan José García-Ripoll @ 2020-08-18 13:36 UTC (permalink / raw)
  To: emacs-devel

Hi,

I am running into a weird issue in Windows 10, both with Emacs 27 and
Emacs 26.3. It all boils down to whether Emacs is invoked from the
command line or not. In one case, subprocesses get their input properly
redirected, in other cases not. All tests are done with plain vanilla
Emacs, using core libraries (no programming mode).

My test files are below. Essentially, the file test.el is trying to
imitate what python.el uses to call a python process, but instead of
that, it uses a simple copycat script that copies the input stream to
the output stream.

- If I launch the program from the command line, as in
      C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs.exe -Q --load c:\Users\juanj\Downloads\test.el
  everything goes fine. In the *Messages* buffer I see this output
"Output:
\"import sys
ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]
ps_json = '\\\\\\\\n[\\\\\\\"%s\\\\\\\", \\\\\\\"%s\\\\\\\", \\\\\\\"%s\\\\\\\"]\\\\\\\\n' % tuple(ps)
print (ps_json)
sys.exit(0)
\""

- If I create a shortcut for runemacs, adding "-Q --load test.el" as
  arguments, then process-file outputs nothing. The *Messages* buffer
  shows  
"Output:
\"\""

- If I type #+R (Windows key + R) and enter directly the command line
"C:\Users\juanj\scoop\apps\emacs-27.1\bin\runemacs -Q --load
c:\Users\juanj\Downloads\test.el" the script also fails and produces the
wrong output.

There are no error messages. The script gets invoked (you may add a line
"echo foo" to chain.cmd and see that it is output), but it does not
get the redirected input.

---foo---(test file 1, saved as c:\Users\juanj\Downloads\foo)
import sys
ps = [getattr(sys, 'ps%s' % i, '') for i in range(1,4)]
ps_json = '\\n[\"%s\", \"%s\", \"%s\"]\\n' % tuple(ps)
print (ps_json)
sys.exit(0)

--test.el---(test file 2, saved as c:\Users\juanj\Downloads\test.el)
(with-current-buffer "*Messages*"
  (with-temp-buffer
    (call-process "c:/Users/juanj/Downloads/chain.cmd" ;conda_python.cmd"
                  "c:/Users/juanj/Downloads/foo"
                  '(t nil) nil "-i")
    (print (format "Output:\n%S" (buffer-string)))
    ))

---chain.cmd---(test file 2, saved as c:\Users\juanj\Downloads\chain.cmd)
@echo off
rem copies lines from the input until it is empty
:begin
set /p line= || goto :end
echo %line%
goto :begin
:end


-- 
Juan José García Ripoll
http://juanjose.garciaripoll.com
http://quinfog.hbar.es




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

end of thread, other threads:[~2020-08-20  7:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-18 13:36 Problems with call-process (= identifying run-python issues) Juan José García-Ripoll
2020-08-18 15:41 ` Eli Zaretskii
     [not found]   ` <CANejTzpQdx=7gzbkV-gzoyFKHx+U1sKy2Uid13g6hpwCa_GnRA@mail.gmail.com>
2020-08-18 16:24     ` Eli Zaretskii
2020-08-19  8:59       ` Juan José García-Ripoll
2020-08-19 14:41         ` Eli Zaretskii
2020-08-19 16:23           ` Juan José García-Ripoll
2020-08-19 17:03             ` Eli Zaretskii
2020-08-20  7:52               ` Juan José García-Ripoll

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.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).