[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:
parent
13ba167baf
commit
2e3ba7996b
2 changed files with 6 additions and 11 deletions
|
@ -1,17 +1,17 @@
|
||||||
|
# vim:et sts=2 sw=2 ft=zsh
|
||||||
#
|
#
|
||||||
# Creates archive files
|
# Creates archive files
|
||||||
#
|
#
|
||||||
|
|
||||||
if (( # < 2 )); then
|
if (( # < 2 )); then
|
||||||
print "usage: ${0} [archive_name.ext] [file]..." >&2
|
print "usage: ${0} <archive_name.ext> <file>..." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we are quitting (above) if there are less than 2 vars,
|
# we are quitting (above) if there are less than 2 vars,
|
||||||
# so we don't need any argc check here.
|
# 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}"
|
||||||
local archive_name="${1:t}"
|
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# pigz and pbzip2 are aliased in the init.zsh file. This provides a significant speedup, resulting in a
|
# pigz and pbzip2 are aliased in the init.zsh file. This provides a significant speedup, resulting in a
|
||||||
|
|
|
@ -1,19 +1,14 @@
|
||||||
|
# vim:et sts=2 sw=2 ft=zsh
|
||||||
#
|
#
|
||||||
# Unarchives files
|
# Unarchives files
|
||||||
#
|
#
|
||||||
|
|
||||||
if (( # != 1 )); then
|
if (( # != 1 )); then
|
||||||
print "usage: ${0} [archive.ext]" >&2
|
print "usage: ${0} <archive_name.ext>" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -s ${1} ]]; then
|
local archive_name="${1}"
|
||||||
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}"
|
|
||||||
|
|
||||||
# using unpigz/pbunzip2 provides little to decompression time; the benefit is mainly in compression time.
|
# 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.
|
# setting it as an alias in the init.zsh file should be sufficient here.
|
||||||
|
|
Loading…
Reference in a new issue