Support redirects with empty commands.

* gash/eval.scm (exp->thunk): Return 'noop' if 'exp' is '#f'.
* tests/50-redirect-clobber.sh: New file.
* tests/50-redirect-clobber.stdout: New file.
* Makefile.am (FULL_TESTS): Add tests/50-redirect-clobber.sh.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
This commit is contained in:
Jan Nieuwenhuizen 2019-01-01 12:24:14 +01:00 committed by Timothy Sample
parent 6808c941f1
commit 7640a09382
4 changed files with 12 additions and 2 deletions

View File

@ -214,6 +214,7 @@ FULL_TESTS = \
tests/50-redirect-sed.sh \
tests/50-redirect-space.sh \
tests/50-redirect-in-out.sh \
tests/50-redirect-clobber.sh \
tests/60-function.sh \
tests/60-function-at.sh \
tests/60-subst.sh \

View File

@ -1,5 +1,6 @@
;;; Gash -- Guile As SHell
;;; Copyright © 2018 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2018, 2019 Timothy Sample <samplet@ngyro.com>
;;; Copyright © 2018, 2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of Gash.
;;;
@ -52,7 +53,10 @@
(_ `(,op ,fd ,field)))))
(define (exp->thunk exp)
(lambda () (eval-sh exp)))
;; XXX: See comment in `exps->thunk'.
(if exp
(lambda () (eval-sh exp))
noop))
(define (exps->thunk exps)
;; XXX: It probably makes more sense to exclude '#f' expressions at

View File

@ -0,0 +1,4 @@
echo foo > /tmp/bar$$
cat /tmp/bar$$
> /tmp/bar$$
cat /tmp/bar$$

View File

@ -0,0 +1 @@
foo