rm: Resurrect.

* gash/commands/rm.scm: Resurrect.
* gash/bournish-commands.scm: Add it.
* build-aux/build-guile.sh: Compile it.
* .gitignore: Ignore it.
This commit is contained in:
Jan Nieuwenhuizen 2018-10-31 22:30:49 +01:00
parent 6224bbeefc
commit aafbc96dbd
5 changed files with 60 additions and 0 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@
/bin/grep
/bin/ls
/bin/reboot
/bin/rm
/bin/sed
/bin/sh
/bin/tar

View File

@ -73,6 +73,7 @@ ${srcdest}bin/gash
${srcdest}bin/grep
${srcdest}bin/ls
${srcdest}bin/reboot
${srcdest}bin/rm
${srcdest}bin/sed
${srcdest}bin/tar
${srcdest}bin/wc

1
configure vendored
View File

@ -96,6 +96,7 @@ find
grep
ls
reboot
rm
sed
tar
wc

View File

@ -38,6 +38,7 @@
#:use-module (gash commands grep)
#:use-module (gash commands ls)
#:use-module (gash commands reboot)
#:use-module (gash commands rm)
#:use-module (gash commands sed)
#:use-module (gash commands tar)
#:use-module (gash commands wc)
@ -52,6 +53,7 @@
grep-command
ls-command
reboot-command
rm-command
sed-command
rm-command
wc-command
@ -76,6 +78,7 @@
(define grep-command (wrap-command "grep" grep))
(define ls-command (wrap-command "ls" ls))
(define reboot-command (wrap-command "reboot" reboot))
(define rm-command (wrap-command "rm" rm))
(define sed-command (wrap-command "sed" sed))
(define tar-command (wrap-command "tar" tar))
(define wc-command (wrap-command "wc" wc))
@ -90,6 +93,7 @@
("grep" . ,grep-command)
("ls" . ,ls-command)
("reboot" . ,reboot-command)
("rm" . ,rm-command)
("sed" . ,sed-command)
("tar" . ,tar-command)
("wc" . ,wc-command)

53
gash/commands/rm.scm Normal file
View File

@ -0,0 +1,53 @@
;;; Gash --- Guile As SHell
;;; Copyright © 2016, 2017 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
;;;
;;; This file is part of Gash.
;;;
;;; Gash is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; Gash is distributed in the hope that it will be useful, but WITHOUT ANY
;;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
;;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
;;; details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with Gash. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;; The initial bournish.scm was taken from Guix.
;;; Code:
(define-module (gash commands rm)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)
#:use-module (gash shell-utils)
#:export (
rm
))
(define (rm name . args)
(let ((recursive? (or (member "-r" args)
(member "-fr" args)
(member "-rf" args)))
(force? (or (member "-f" args)
(member "-rf" args)
(member "-fr" args)))
(files (filter (negate (cut string-prefix? "-" <>)) args)))
(catch #t
(lambda _
(if recursive? (for-each delete-file-recursively files)
(for-each delete-file files))
#t)
(lambda ( . rest)
(or force?
(apply throw rest))))))
(define main rm)