unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: vapnik spaknik <vapniks@yahoo.com>
To: guile users mailing list <guile-user@gnu.org>
Subject: system command output different in guile than on command line
Date: Tue, 4 Aug 2020 21:34:22 +0000 (UTC)	[thread overview]
Message-ID: <1155809260.1393834.1596576862334@mail.yahoo.com> (raw)
In-Reply-To: 1155809260.1393834.1596576862334.ref@mail.yahoo.com

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	other threads:[~2020-08-04 21:34 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 ` vapnik spaknik [this message]
2020-08-05  7:47   ` system command output different in guile than on command line tomas
2020-08-05 11:27   ` vapnik spaknik via General Guile related discussions
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=1155809260.1393834.1596576862334@mail.yahoo.com \
    --to=vapniks@yahoo.com \
    --cc=guile-user@gnu.org \
    /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).