guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: system command output different in guile than on command line


From: vapnik spaknik
Subject: Re: system command output different in guile than on command line
Date: Wed, 5 Aug 2020 11:27:30 +0000 (UTC)

 

On Tuesday, August 4, 2020, 10:34:22 PM GMT+1, vapnik spaknik 
<vapniks@yahoo.com> wrote:


>Hi,
>    I'm trying to write some code to get the size of a diff of two files.
>If I run the following pipeline in my zsh shell:
>
>> diff -ua /tmp/file1 /tmp/file2 | wc -c
>
>it prints 215
>However when I run the following in guile:
>
>guile> (system "diff -ua /tmp/file1 /tmp/file2 | wc -c")
>
>it prints 243.

OK... I was being stupid. The shell command that I actually ran was: diff -ua 
file1 file2 | wc -c
i.e. without the directories in the paths since I was running from within /tmp
This meant the command I ran in the shell was slightly different than the one 
ran in guile, and hence the difference in diffs.
However, I'm still perplexed by the non-zero error code returned in the 
pipeline:

>Another strange thing is that if I use the pipeline procedure to do the same 
>thing, then I get an exit code of 1 >from the wc command, but it still returns 
>the same result:

>(define (diffsize f1 f2)
>  (receive (from to pids)
>      (pipeline (list (list "/usr/bin/diff" "-ua" f1 f2)
>              (list "/usr/bin/wc" "-c")))
>    (let ((rval (cons f2 (string->number
>              (string-delete #\newline
>                    (read-delimited " " from)))))
>      (xvals (map (compose status:exit-val cdr waitpid) pids)))
>      (close to)
>      (close from)
>      (format #t "Exit values: ~a\n" xvals)
>      rval)))
>
>guile> (diffsize "/tmp/file1" "/tmp/file2")
>Exit values: (0 1)
>("/tmp/file2" . 243)
>
>Why?
  

reply via email to

[Prev in Thread] Current Thread [Next in Thread]