many bugfix, fixed getopt split
This commit is contained in:
+20
-8
@@ -250,10 +250,13 @@ utaz()
|
||||
return 1
|
||||
fi
|
||||
# getopt emits a shell-quoted, normalised argument list ("--" terminates the
|
||||
# options); re-evaluating it restores the arguments with spaces and quotes
|
||||
# intact. Declared local so flags never leak in from the caller's environment.
|
||||
# options); _getopt_split rebuilds the arguments from it (spaces and quotes
|
||||
# intact, no eval). The flags are declared local so that none leaks in from
|
||||
# the caller's environment.
|
||||
local willrm="" createdir="" nodir="" icase="" csens=""
|
||||
eval set -- "$PARSED"
|
||||
local -a _pargs=()
|
||||
_getopt_split _pargs "$PARSED"
|
||||
set -- "${_pargs[@]}"
|
||||
while true; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
@@ -359,7 +362,12 @@ utaz()
|
||||
elif [[ -d "$zitem" ]]; then
|
||||
# Only direct children are considered (no recursion); NUL-separated
|
||||
# so names containing spaces or newlines survive.
|
||||
mapfile -d '' -t targets < <(find "$zitem" -mindepth 1 -maxdepth 1 -print0 2>/dev/null)
|
||||
# ("mapfile -d" needs bash 4.4, the profile supports 4.3)
|
||||
local _zt
|
||||
targets=()
|
||||
while IFS= read -r -d '' _zt; do
|
||||
targets+=("$_zt")
|
||||
done < <(find "$zitem" -mindepth 1 -maxdepth 1 -print0 2>/dev/null)
|
||||
if [[ ${#targets[@]} -eq 0 ]]; then
|
||||
disp I "Directory ${zitem} is empty, skipping."
|
||||
continue
|
||||
@@ -517,11 +525,13 @@ utaz()
|
||||
# top-level directory (it then acts as the host directory).
|
||||
# nullglob makes the array empty when nothing matches; dotglob
|
||||
# makes hidden entries count, so ".git" alone is not ignored.
|
||||
local _old_glob
|
||||
_old_glob=$(shopt -p nullglob dotglob)
|
||||
local _had_ng=0 _had_dg=0
|
||||
shopt -q nullglob && _had_ng=1
|
||||
shopt -q dotglob && _had_dg=1
|
||||
shopt -s nullglob dotglob
|
||||
local contents=( "${dir}"/* )
|
||||
eval "$_old_glob"
|
||||
(( _had_ng )) || shopt -u nullglob
|
||||
(( _had_dg )) || shopt -u dotglob
|
||||
[[ ${#contents[@]} -eq 1 && -d "${contents[0]}" && ! -L "${contents[0]}" ]] && flatten=1
|
||||
fi
|
||||
|
||||
@@ -719,7 +729,9 @@ taz()
|
||||
# See utaz: restore the getopt-normalised argument list, and keep every
|
||||
# flag local so nothing leaks in from the caller's environment.
|
||||
local willrm="" keepall="" verbose="" quiet="" nproc="" complevel=""
|
||||
eval set -- "$PARSED"
|
||||
local -a _pargs=()
|
||||
_getopt_split _pargs "$PARSED"
|
||||
set -- "${_pargs[@]}"
|
||||
local compforms=()
|
||||
local _f _list
|
||||
while true; do
|
||||
|
||||
Reference in New Issue
Block a user