diff options
author | Ricardo Wurmus <rekado@elephly.net> | 2017-01-25 20:52:27 +0100 |
---|---|---|
committer | Ricardo Wurmus <rekado@elephly.net> | 2017-01-26 13:49:56 +0100 |
commit | 0db2ff65e7101951fedf4357aa37aaf92f7df431 (patch) | |
tree | 9111445a899fd8815785c5a968087a31b5eb77e4 /guix | |
parent | 2f977d92d3ae517788d3dee98f63680ca149aa1a (diff) | |
download | gnu-guix-0db2ff65e7101951fedf4357aa37aaf92f7df431.tar gnu-guix-0db2ff65e7101951fedf4357aa37aaf92f7df431.tar.gz |
bournish: Extend 'rm' command.
* guix/build/bournish.scm (rm-command): New procedure.
(%commands): Use it.
* tests/bournish.scm: Add tests for "rm" and "rm -r".
Diffstat (limited to 'guix')
-rw-r--r-- | guix/build/bournish.scm | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/guix/build/bournish.scm b/guix/build/bournish.scm index 51dad17ba7..e948cd03d3 100644 --- a/guix/build/bournish.scm +++ b/guix/build/bournish.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il> +;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net> ;;; ;;; This file is part of GNU Guix. ;;; @@ -105,6 +106,14 @@ characters." ((@ (guix build utils) dump-port) port (current-output-port)) *unspecified*))) +(define (rm-command . args) + "Emit code for the 'rm' command." + (cond ((member "-r" args) + `(for-each (@ (guix build utils) delete-file-recursively) + (list ,@(delete "-r" args)))) + (else + `(for-each delete-file (list ,@args))))) + (define (lines+chars port) "Return the number of lines and number of chars read from PORT." (let loop ((lines 0) (chars 0)) @@ -194,7 +203,7 @@ commands such as 'ls' and 'cd'; it lacks globbing, pipes---everything.\n")) `(("echo" ,(lambda strings `(list ,@strings))) ("cd" ,(lambda (dir) `(chdir ,dir))) ("pwd" ,(lambda () `(getcwd))) - ("rm" ,(lambda (file) `(delete-file ,file))) + ("rm" ,rm-command) ("cp" ,(lambda (source dest) `(copy-file ,source ,dest))) ("help" ,help-command) ("ls" ,ls-command) |