implement rm command

This commit is contained in:
2025-09-09 17:36:39 -07:00
parent eb440261d7
commit 021eac1949

View File

@@ -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" _)