[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Add 'guix hash'.
From: |
Nikita Karetnikov |
Subject: |
Re: [PATCH] Add 'guix hash'. |
Date: |
Wed, 10 Apr 2013 15:48:49 +0400 |
> Ah, TOCTTOU, right.
> You could do:
> (let ((hash (catch 'system-error
> (lambda ()
> (call-with-input-file ...))
> (lambda args
> (leave (_ "error ..." (strerror (system-error-errno
> args))))))))
> ...)
Here is what I did (I'll remove "guix hash" when we have "warning"):
(match args
((file)
(catch 'system-error
(lambda ()
(format #t "~a~%"
(call-with-input-file file
(compose fmt sha256 get-bytevector-all))))
(lambda args
(leave (_ "~a: ~a~%")
"guix hash" (strerror (system-error-errno args))))))
(_
(leave (_ "~a: wrong number of arguments~%")
"guix hash")))))
I guess that "wrong number of arguments" can be handled by
(lambda args ...). Still, the above feels much safer.
What do you think?
pgpxlwcsCQ622.pgp
Description: PGP signature
- [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/01
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/03
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/05
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/05
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/05
- Re: [PATCH] Add 'guix hash'.,
Nikita Karetnikov <=
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/10
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/10
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/10
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/05
- Re: [PATCH] Add 'guix hash'., Nikita Karetnikov, 2013/04/09
- Re: [PATCH] Add 'guix hash'., Ludovic Courtès, 2013/04/11
- master: FAIL: tests/guix-package.sh (was: [PATCH] Add 'guix hash'.), Nikita Karetnikov, 2013/04/12
- Re: master: FAIL: tests/guix-package.sh, Nikita Karetnikov, 2013/04/12
- Re: master: FAIL: tests/guix-package.sh, Ludovic Courtès, 2013/04/12
- Enhanced 'warning' (was: [PATCH] Add 'guix hash'.), Nikita Karetnikov, 2013/04/18