unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Program working with shell-command but not call-process
@ 2014-07-03 16:46 John Mastro
  2014-07-03 22:51 ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: John Mastro @ 2014-07-03 16:46 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Does anyone know what situation would result in this working:

    (shell-command-to-string "git --version")
    ;=> it returns "git version 2.0.1"

But not this:

    (with-output-to-string
      (call-process "git" nil standard-output nil "--version"))
      ;=> it returns ""
      ;=> `call-process' alone returns 53

This git is built and installed from source on Cygwin. It works fine
from the shell but not via `call-process', which means it doesn't work
with `magit'.

It's in my path (both $PATH and `exec-path'), and `executable-find'
finds it without problem at c:/usr/local/bin/git.exe.

The git that's availablefor install via Cygwin (quite old, v1.7.9),
succeeds with both the calls above. It's still installed at
c:/bin/git.exe.

Thanks,

John


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

* Re: Program working with shell-command but not call-process
  2014-07-03 16:46 Program working with shell-command but not call-process John Mastro
@ 2014-07-03 22:51 ` Michael Heerdegen
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2014-07-03 22:51 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro <john.b.mastro@gmail.com> writes:

> Does anyone know what situation would result in this working:
>
>     (shell-command-to-string "git --version")
>     ;=> it returns "git version 2.0.1"
>
> But not this:
>
>     (with-output-to-string
>       (call-process "git" nil standard-output nil "--version"))
>       ;=> it returns ""
>       ;=> `call-process' alone returns 53

Don't know anything about this, sorry.  But considering the doc of
`call-process` - when you don't get a lisp error, Emacs found and
actually called git, and git exited with return value 53.

Dunno what makes the difference when you use a shell.

Michael.




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

* Re: Program working with shell-command but not call-process
       [not found] <mailman.4812.1404406058.1147.help-gnu-emacs@gnu.org>
@ 2014-07-04 10:16 ` Joost Kremers
  2014-07-04 15:21   ` Michael Heerdegen
  0 siblings, 1 reply; 4+ messages in thread
From: Joost Kremers @ 2014-07-04 10:16 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro wrote:
> Does anyone know what situation would result in this working:
>
>     (shell-command-to-string "git --version")
>     ;=> it returns "git version 2.0.1"
>
> But not this:
>
>     (with-output-to-string
>       (call-process "git" nil standard-output nil "--version"))
>       ;=> it returns ""
>       ;=> `call-process' alone returns 53

`with-output-to-string' takes whatever is sent to `standard-output',
converts it to a string and returns it. `call-process' sends its output
to a buffer, or optionally to a file, but not to stdout. So you won't
get any output from this construct unless `standard-output' is set to a
buffer.

However, that is probably not the source of the problem you hint at (the
fact that magit doesn't work). That is most likely due to the fact that
`call-process' alone returns 53. If git were successful, it should
return 0.


-- 
Joost Kremers                                   joostkremers@fastmail.fm
Selbst in die Unterwelt dringt durch Spalten Licht
EN:SiS(9)


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

* Re: Program working with shell-command but not call-process
  2014-07-04 10:16 ` Joost Kremers
@ 2014-07-04 15:21   ` Michael Heerdegen
  0 siblings, 0 replies; 4+ messages in thread
From: Michael Heerdegen @ 2014-07-04 15:21 UTC (permalink / raw)
  To: help-gnu-emacs

Joost Kremers <joost.m.kremers@gmail.com> writes:

> >     (with-output-to-string
> >       (call-process "git" nil standard-output nil "--version"))
> >       ;=> it returns ""
> >       ;=> `call-process' alone returns 53
>
> `with-output-to-string' takes whatever is sent to `standard-output',
> converts it to a string and returns it. `call-process' sends its output
> to a buffer, or optionally to a file, but not to stdout. So you won't
> get any output from this construct unless `standard-output' is set to a
> buffer.

I don't think this is true.  `with-output-to-string` binds
`standard-output` to a temporary buffer and returns its content, so the
above should work (and actually does work here).

Michael.




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

end of thread, other threads:[~2014-07-04 15:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03 16:46 Program working with shell-command but not call-process John Mastro
2014-07-03 22:51 ` Michael Heerdegen
     [not found] <mailman.4812.1404406058.1147.help-gnu-emacs@gnu.org>
2014-07-04 10:16 ` Joost Kremers
2014-07-04 15:21   ` Michael Heerdegen

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