mv: New builtin.

* gash/commands/mv.scm: New file.
* gash/bournish-commands.scm: Use it.
* build-aux/build-guile.sh: Compile it.
* configure: Wrap it.
* .gitignore: Ignore it.
This commit is contained in:
Jan Nieuwenhuizen 2018-11-30 12:26:28 +01:00
parent 1162f37d19
commit 0a09ab114a
6 changed files with 64 additions and 6 deletions

2
.gitignore vendored
View File

@ -12,12 +12,14 @@
/bin/grep
/bin/ls
/bin/mkdir
/bin/mv
/bin/reboot
/bin/rm
/bin/rmdir
/bin/sed
/bin/sh
/bin/tar
/bin/touch
/bin/wc
/bin/which
/.config.make

View File

@ -66,6 +66,7 @@ ${srcdest}gash/commands/find.scm
${srcdest}gash/commands/grep.scm
${srcdest}gash/commands/ls.scm
${srcdest}gash/commands/mkdir.scm
${srcdest}gash/commands/mv.scm
${srcdest}gash/commands/reboot.scm
${srcdest}gash/commands/rm.scm
${srcdest}gash/commands/rmdir.scm
@ -89,6 +90,7 @@ ${srcdest}bin/gash
${srcdest}bin/grep
${srcdest}bin/ls
${srcdest}bin/mkdir
${srcdest}bin/mv
${srcdest}bin/reboot
${srcdest}bin/rm
${srcdest}bin/rmdir

1
configure vendored
View File

@ -102,6 +102,7 @@ find
grep
ls
mkdir
mv
reboot
rm
rmdir

View File

@ -39,6 +39,8 @@
#:use-module (gash commands find)
#:use-module (gash commands grep)
#:use-module (gash commands ls)
#:use-module (gash commands mkdir)
#:use-module (gash commands mv)
#:use-module (gash commands reboot)
#:use-module (gash commands rm)
#:use-module (gash commands sed)
@ -57,6 +59,8 @@
find-command
grep-command
ls-command
mkdir-command
mv-command
reboot-command
rm-command
sed-command
@ -86,7 +90,8 @@
(define find-command (wrap-command "find" find))
(define grep-command (wrap-command "grep" grep))
(define ls-command (wrap-command "ls" ls))
(define mkdir-command (wrap-command "mkdir" mkdir))
(define mkdir-command (wrap-command "mkdir" mkdir'))
(define mv-command (wrap-command "mv" mv))
(define reboot-command (wrap-command "reboot" reboot'))
(define rm-command (wrap-command "rm" rm))
(define rmdir-command (wrap-command "rmdir" rmdir))
@ -106,7 +111,8 @@
("find" . ,find-command)
("grep" . ,grep-command)
("ls" . ,ls-command)
("mkdir" . ,mkdir)
("mkdir" . ,mkdir-command)
("mv" . ,mv-command)
("reboot" . ,reboot-command)
("rm" . ,rm-command)
("rmdir" . ,rmdir-command)

View File

@ -35,10 +35,10 @@
#:use-module (gash shell-utils)
#:export (
mkdir
mkdir'
))
(define (mkdir . args)
(define (mkdir' . args)
(let* ((option-spec
'((help (single-char #\h))
(mode (single-char #\m) (value #t))
@ -67,8 +67,8 @@ Options:
")
(exit (if usage? 2 0)))
(else
(let ((mode (if mode (umask (chmodifiers->mode (parse-modifiers mode)))
(let ((mode (if mode (umask (chmodifiers->mode (parse-chmodifiers mode)))
#o755)))
(for-each (if parents? mkdir-p (@ (guile) mkdir)) files))))))
(define main mkdir)
(define main mkdir')

47
gash/commands/mv.scm Normal file
View File

@ -0,0 +1,47 @@
;;; Gash --- Guile As SHell
;;; 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:
;;; Code:
(define-module (gash commands mv)
#:use-module (ice-9 match)
#:use-module (srfi srfi-26)
#:use-module (gash config)
#:use-module (gash shell-utils)
#:export (
mv
))
(define (mv name . args)
(match args
((or "-h" "--help")
(format #t "mv SOURCE... DEST\n"))
((or "-V" "--version")
(format #t "mv (GASH) ~a\n" %version) (exit 0))
((source dest)
(rename-file source dest))
((sources ... dest)
(unless (directory-exists? dest)
(error (format #f "mv: target `~a' is not a directory\n" dest)))
(for-each rename-file
sources
(map (cut string-append dest "/" <>) sources)))))
(define main mv)