guile-user
[Top][All Lists]
Advanced

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

system command output different in guile than on command line


From: vapnik spaknik
Subject: system command output different in guile than on command line
Date: Tue, 4 Aug 2020 21:34:22 +0000 (UTC)

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.
I've tried for other pairs of files, and the difference between the command 
line results and the guile results always seems to be 28.
This is not too much of a problem in itself because I can just subtract 28 in 
my guile code, but it worries me; why the discrepancy? Are there other 
differences between guile system calls and the command line that I need to be 
aware of?
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]