implement rm command
This commit is contained in:
17
palps.rkt
17
palps.rkt
@@ -112,10 +112,21 @@
|
|||||||
(flush-output)]
|
(flush-output)]
|
||||||
|
|
||||||
[(list _ "ed" name)
|
[(list _ "ed" name)
|
||||||
(let ([path (if (file-exists? name)
|
(let ([path (build-path (current-directory)
|
||||||
(ed (our-make-temporary-file name))
|
(string->path-element name))])
|
||||||
|
(let ([path (if (file-exists? path)
|
||||||
|
(ed (our-make-temporary-file path))
|
||||||
(ed))])
|
(ed))])
|
||||||
(copy-file path name #:exists-ok? #t))]
|
(copy-file path name #:exists-ok? #t)))]
|
||||||
|
|
||||||
|
[(list _ "rm" name)
|
||||||
|
(let ([path (build-path (current-directory)
|
||||||
|
(string->path-element name))])
|
||||||
|
(if (file-exists? path)
|
||||||
|
(delete-file path)
|
||||||
|
(displayln "file does not exist"))
|
||||||
|
|
||||||
|
(flush-output))]
|
||||||
|
|
||||||
[(or (list _ "bye" _)
|
[(or (list _ "bye" _)
|
||||||
(list _ "b" _)
|
(list _ "b" _)
|
||||||
|
|||||||
Reference in New Issue
Block a user