Restructure variable initialization.
This commit is contained in:
parent
975f0a194e
commit
4cf714ce5c
1 changed files with 21 additions and 15 deletions
36
tarback.sh
36
tarback.sh
|
@ -1,27 +1,33 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -eu
|
||||
|
||||
XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||
XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"
|
||||
|
||||
TARBACK_REMOTE_DEFAULT=
|
||||
TARBACK_TRANSFORM_REMOTE_COMMAND_DEFAULT=
|
||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||
TARBACK_TAR_CREATE_COMMAND_DEFAULT='tar c -C "$(dirname "$1")" "$(basename "$1")"'
|
||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||
TARBACK_TAR_EXTRACT_COMMAND_DEFAULT='tar x -C "$(dirname "$1")"'
|
||||
TARBACK_COMPRESSION_DEFAULT='xz'
|
||||
TARBACK_SPLIT_DEFAULT="split -b $((128*1024*1024)) -"
|
||||
TARBACK_MERGE_DEFAULT='cat'
|
||||
TARBACK_PLUGIN_SEARCH_PATH_DEFAULT="$(dirname "$0"):$XDG_DATA_HOME:$XDG_DATA_DIRS"
|
||||
|
||||
|
||||
# example: TARBACK_REMOTE="ssh myuser@myserver" ./tarback ...
|
||||
TARBACK_REMOTE="${TARBACK_REMOTE:-}"
|
||||
TARBACK_REMOTE="${TARBACK_REMOTE:-$TARBACK_REMOTE_DEFAULT}"
|
||||
# maybe the command needs to be transformed before being passed to the
|
||||
# remote command, see _transform_ssh_command for an example
|
||||
TARBACK_TRANSFORM_REMOTE_COMMAND="${TARBACK_TRANSFORM_REMOTE_COMMAND:-}"
|
||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||
[ -z "$TARBACK_TAR_CREATE_COMMAND" ] \
|
||||
&& TARBACK_TAR_CREATE_COMMAND='tar c -C "$(dirname "$1")" "$(basename "$1")"'
|
||||
# shellcheck disable=SC2016 # disable variable not expanding hint
|
||||
[ -z "$TARBACK_TAR_EXTRACT_COMMAND" ] \
|
||||
&& TARBACK_TAR_EXTRACT_COMMAND='tar x -C "$(dirname "$1")"'
|
||||
[ -z "$TARBACK_COMPRESSION" ] && TARBACK_COMPRESSION="xz"
|
||||
[ -z "$TARBACK_SPLIT" ] && TARBACK_SPLIT="split -b $((128*1024*1024)) -"
|
||||
[ -z "$TARBACK_MERGE" ] && TARBACK_MERGE='cat'
|
||||
[ -z "$TARBACK_PLUGIN_SEARCH_PATH" ] \
|
||||
&& TARBACK_PLUGIN_SEARCH_PATH="$(dirname "$0"):$XDG_DATA_HOME:$XDG_DATA_DIRS"
|
||||
|
||||
TARBACK_TRANSFORM_REMOTE_COMMAND="${TARBACK_TRANSFORM_REMOTE_COMMAND:-$TARBACK_TRANSFORM_REMOTE_COMMAND_DEFAULT}"
|
||||
TARBACK_TAR_CREATE_COMMAND="${TARBACK_TAR_CREATE_COMMAND:-$TARBACK_TAR_CREATE_COMMAND_DEFAULT}"
|
||||
TARBACK_TAR_EXTRACT_COMMAND="${TARBACK_TAR_EXTRACT_COMMAND:-$TARBACK_TAR_EXTRACT_COMMAND_DEFAULT}"
|
||||
TARBACK_COMPRESSION="${TARBACK_COMPRESSION:-$TARBACK_COMPRESSION_DEFAULT}"
|
||||
TARBACK_SPLIT="${TARBACK_SPLIT:-$TARBACK_SPLIT_DEFAULT}"
|
||||
TARBACK_MERGE="${TARBACK_MERGE:-$TARBACK_MERGE_DEFAULT}"
|
||||
TARBACK_PLUGIN_SEARCH_PATH="${TARBACK_PLUGIN_SEARCH_PATH:-$TARBACK_PLUGIN_SEARCH_PATH_DEFAULT}"
|
||||
TARBACK_PLUGIN_SEARCH_PATH="$(echo "$TARBACK_PLUGIN_SEARCH_PATH" | tr ':' '\n')"
|
||||
|
||||
_transform_split_name() {
|
||||
|
|
Loading…
Reference in a new issue