1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00

[archive] Allow archives in any directory

Current code will create an archive in the current directory with:

    % archive ../test.tar.gz test.*

or will complain that the following archive doesn't exist in the current
directory (given it actually exists in the parent one):

    % unarchive ../test.tar.gz

Fix that and allow archives in any directory.

Other changes:

* Use `<required_param>` instead of `[required_param]` in the usage text
* Don't explictly check if archive exists in `unarchive`, but let the
  respective tool fail with its own message

Closes #312
This commit is contained in:
Eric Nielsen 2018-11-24 22:45:08 -05:00 committed by GitHub
parent 13ba167baf
commit 2e3ba7996b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 11 deletions

View file

@ -1,17 +1,17 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Creates archive files
#
if (( # < 2 )); then
print "usage: ${0} [archive_name.ext] [file]..." >&2
print "usage: ${0} <archive_name.ext> <file>..." >&2
return 1
fi
# we are quitting (above) if there are less than 2 vars,
# so we don't need any argc check here.
# strip the path, just in case one is provided for some reason
local archive_name="${1:t}"
local archive_name="${1}"
shift
# pigz and pbzip2 are aliased in the init.zsh file. This provides a significant speedup, resulting in a

View file

@ -1,19 +1,14 @@
# vim:et sts=2 sw=2 ft=zsh
#
# Unarchives files
#
if (( # != 1 )); then
print "usage: ${0} [archive.ext]" >&2
print "usage: ${0} <archive_name.ext>" >&2
return 1
fi
if [[ ! -s ${1} ]]; then
print "archive \"${1}\" was not found or has size 0." >&2
return 1
fi
# strip the path, just in case one is provided for some reason
local archive_name="${1:t}"
local archive_name="${1}"
# using unpigz/pbunzip2 provides little to decompression time; the benefit is mainly in compression time.
# setting it as an alias in the init.zsh file should be sufficient here.