unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: vapnik spaknik via General Guile related discussions <guile-user@gnu.org>
To: guile users mailing list <guile-user@gnu.org>
Subject: Re: system command output different in guile than on command line
Date: Wed, 5 Aug 2020 11:27:30 +0000 (UTC)	[thread overview]
Message-ID: <1535616889.169339.1596626850371@mail.yahoo.com> (raw)
In-Reply-To: <1155809260.1393834.1596576862334@mail.yahoo.com>

 

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?
  


  parent reply	other threads:[~2020-08-05 11:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1155809260.1393834.1596576862334.ref@mail.yahoo.com>
2020-08-04 21:34 ` system command output different in guile than on command line vapnik spaknik
2020-08-05  7:47   ` tomas
2020-08-05 11:27   ` vapnik spaknik via General Guile related discussions [this message]
2020-08-05 12:24     ` tomas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1535616889.169339.1596626850371@mail.yahoo.com \
    --to=guile-user@gnu.org \
    --cc=vapniks@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).