tar: Support old cvf/xvf and auto-compress.

* gash/bournish-commands.scm (tar-command): Support old cvf/xvf and
auto compress (use archive suffix to determine the compression.
This commit is contained in:
Jan Nieuwenhuizen 2018-10-27 22:14:44 +02:00
parent a10247aab1
commit d2133b8502
1 changed files with 20 additions and 6 deletions

View File

@ -401,6 +401,20 @@ Options:
(version (single-char #\V))))
(args (cons "tar" args))
(options (getopt-long args option-spec))
(options (if (or (option-ref options 'create #f)
(option-ref options 'extract #f)
(option-ref options 'list #f)
(null? (cdr args))
(string-prefix? "-" (cadr args))) options
(let ((args (cons* (car args)
(string-append "-" (cadr args))
(cddr args))))
(getopt-long args option-spec))))
(create? (option-ref options 'create #f))
(list? (option-ref options 'list #f))
(extract? (option-ref options 'extract #f))
(file (option-ref options 'file "-"))
(files (option-ref options '() '()))
(compress? (option-ref options 'compress #f))
(bzip2? (option-ref options 'bzip2 #f))
(gzip? (option-ref options 'gzip #f))
@ -409,12 +423,12 @@ Options:
(compress? 'compress)
(gzip? 'gzip)
(xz? 'xz)
(else #f)))
(create? (option-ref options 'create #f))
(list? (option-ref options 'list #f))
(extract? (option-ref options 'extract #f))
(file (option-ref options 'file "-"))
(files (option-ref options '() '()))
(else (and (or extract? list? )
(cond ((string-suffix? ".Z" file) 'compress)
((string-suffix? ".bz2" file) 'bzip2)
((string-suffix? ".gz" file) 'gzip)
((string-suffix? ".xz" file) 'xz)
(else #f))))))
(help? (option-ref options 'help #f))
(usage? (and (not help?) (not (or (and create? (pair? files))
extract? list?))))