* System commands with error escaping
@ 2014-11-26 21:18 白熊 @相撲道
2014-11-27 6:45 ` Thien-Thi Nguyen
0 siblings, 1 reply; 3+ messages in thread
From: 白熊 @相撲道 @ 2014-11-26 21:18 UTC (permalink / raw)
To: guile-user
Hello everyone:
I'd like to ask for help with the following:
I'm programming a Guile automation interface for GNU software compilation and need to issue system calls with error escaping. I have package recipes, which then issue mostly specific configure and make system calls and need to catch errors, that mostly happen during configure and make runs.
Currently, I use the following to issue the configure and make recipes:
(use-modules (ice-9 popen)
(ice-9 rdelim))
(let* ((port (open-input-pipe command-string))
(str (read-line port)))
(close-pipe port)
str)
where command-string is the configure syntax or whatever...
The problem with this is, when configure fails for example due to an error, I don't catch the error and next command gets executed... But I need to catch the error and stop Guile from proceeding, so I see what happened.
How can I best do this?
Thanks a lot for any advice.
--
白熊 @相撲道
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: System commands with error escaping
2014-11-26 21:18 System commands with error escaping 白熊 @相撲道
@ 2014-11-27 6:45 ` Thien-Thi Nguyen
2014-11-27 11:12 ` 白熊@相撲道
0 siblings, 1 reply; 3+ messages in thread
From: Thien-Thi Nguyen @ 2014-11-27 6:45 UTC (permalink / raw)
To: guile-user
[-- Attachment #1: Type: text/plain, Size: 1769 bytes --]
() "白熊 @相撲道" <guile-user_gnu.org@sumou.com>
() Thu, 27 Nov 2014 00:18:22 +0300
The problem with this is, when configure fails for example due
to an error, I don't catch the error and next command gets
executed... But I need to catch the error and stop Guile from
proceeding, so I see what happened.
How can I best do this?
Personally, i use ‘(ttn-do zzz subprocess) call-process’, from
package ttn-do (http://www.gnuvola.org/software/ttn-do/). Here is
its description (excerpt from .info file):
-- Scheme Procedure: call-process program [keyword value…]
Keywords: inp, outp, errp, norm, args
Call PROGRAM synchronously in separate process. Unless given
‘#:outp 0’, wait for PROGRAM to terminate and return a numeric exit
status.
‘#:inp (current-input-port)’
Input port. ‘#f’ means ‘/dev/null’.
‘#:outp (current-output-port)’
Output port. ‘#f’ means discard output; 0 (zero) means
discard, don’t wait for PROGRAM to terminate, and return ‘#f’.
‘#:errp (current-error-port)’
Error output port. ‘#f’ means discard output.
‘#:norm #f’
Non-‘#f’ means PROGRAM and ARGS should be passed through
‘args->normalized-list’.
‘#:args ()’
List of additional args to pass to PROGRAM.
See also ‘make-buffered-caller’ in that module for a more involved
(albeit still synchronous) interface.
--
Thien-Thi Nguyen
GPG key: 4C807502
(if you're human and you know it)
read my lisp: (responsep (questions 'technical)
(not (via 'mailing-list)))
=> nil
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: System commands with error escaping
2014-11-27 6:45 ` Thien-Thi Nguyen
@ 2014-11-27 11:12 ` 白熊@相撲道
0 siblings, 0 replies; 3+ messages in thread
From: 白熊@相撲道 @ 2014-11-27 11:12 UTC (permalink / raw)
To: guile-user
On 2014年11月27日 9:45:26 GMT+03:00, Thien-Thi Nguyen <ttn@gnu.org> wrote:
>
>Personally, i use ‘(ttn-do zzz subprocess) call-process’, from
>package ttn-do (http://www.gnuvola.org/software/ttn-do/).
Hi:
Thanks for the recommendation. I've inspected ttn-do, however it seems too old to me, for instance relies on the obsolete (ice-9 optargs-kw). Didn't check further, anyhow couldn't build it...
I've settled on the simple approach now:
(let ((return (system command-string)))
(if (not (eqv? 0 return))
(throw 'error)))
Which stop fine if run like this. However the problem is, if I define a routine like this:
(define (test-command command-string)
(let ((return (system command-string)))
(if (not (eqv? 0 return))
(throw 'error))))
then call it from somewhere, it doesn't halt code execution, throws the error, then continues with other commands, that follow the test-command call...
Tried with (exit) instead of (throw 'error), but same thing, can't initiate a break of all subroutines and immediate code execution halt, with no further commands.
I'm sure I'm missing something simple... Can anyone point me in the right direction?
--
白熊@相撲道
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-11-27 11:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 21:18 System commands with error escaping 白熊 @相撲道
2014-11-27 6:45 ` Thien-Thi Nguyen
2014-11-27 11:12 ` 白熊@相撲道
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).