#!/bin/bash
#  sys/tool/tar - tar support

set -e


######
# Native dependencies

sys_tool_tar_client_packages=( tar gzip bzip2 ncompress xz-utils )


######
# Settings

sys_tool_tar_config_init() {
	lib_setting_vars tar_verbose
	tar_verbose="${tar_verbose:-false}"

	lib_setting_vars --null tardir

	lib_setting_arrays tar_exclude_ignore

	lib_setting_arrays tar_file_extensions
	tar_file_extensions=( tar.bz2 tar.gz tar.xz tar.Z )
#;	tar_file_extension_aliases=( tbz2 tgz txz )

	# base option support (can be used to add additional global options)
	lib_setting_arrays tar_opts
}


######
# Internal functions

tar_options() {
	! $tar_verbose || tar_opts+=( $var -v )
	[ -z "$tardir" ] || tar_opts+=( $var -C "$tardir" )

	for_each tar_opt_exclude_ignore "${tar_exclude_ignore[@]}"
}

tar_opt_exclude_ignore() { tar_opts+=( --exclude-ignore="$1" ); }


######
# Public interface

tar_filename() { echo "$1.tar"; }

tar_create() {
	local archive=$1
	shift
	local -a tar_opts
	tar_options
	file_mkdir "$archive"
	run tar "${tar_opts[@]}" -acf "$archive" "$@"
}

tar_test() {
	local archive=$1
	local -a tar_opts
	tar_options
	run tar "${tar_opts[@]}" -tf "$archive"
}

tar_extract() {
	local archive=$1
	local -a tar_opts
	tar_options
	run tar "${tar_opts[@]}" -xf "$archive"
}

View the Developer Guide Index

View the Reference Manual Index


Generated on Fri Jul 28 14:36:16 PDT 2017 by mcsh d14 v0.23.0.