;; @module 7tgz.lsp ;; @author Cyril Slobin ;; @description 7z tar+gzip single pass ;; 7z archiver can do both tar and gzip, but not tgz in a single pass. ;; This is an example of using newlisp where shell is usually used. (define (enquo x) (append "\"" x "\"")) (setq usage "Usage: 7tgz a|x archive [files...]") (setq argv (2 (main-args))) (if (< (length argv) 2) (begin (println usage) (exit))) (setq command (argv 0)) (setq archive (argv 1)) (setq files (2 argv)) (regex {^(.*?)(|\.[^.]*)$} archive) (setq basename $1) (setq ext $2) (if (= ext "") (setq archive (append basename ".tgz"))) (setq tarfile (append basename ".tar")) (if (file? tarfile) (begin (println "%s exist; maybe you need it?") (exit))) (setq archiveqq (enquo archive)) (setq tarfileqq (enquo tarfile)) (setq filesqq (join (map enquo files) " ")) (case command ("a" (! (format "7z a -ttar -- %s %s" tarfileqq filesqq)) (! (format "7z a -tgzip -- %s %s" archiveqq tarfileqq)) (delete-file tarfile)) ("x" (! (format "7z x -so -- %s > %s" archiveqq tarfileqq)) (! (format "7z x %s -- %s" tarfileqq filesqq)) (delete-file tarfile)) (true (println usage) (exit))) (exit)