Skip to content

Commit 88c671a

Browse files
committed
tar: Detect GNU/other from --version only once per session
1 parent 7ab05bf commit 88c671a

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

completions/tar

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,25 @@ _posix_tar()
696696

697697
_tar()
698698
{
699-
local cmd=${COMP_WORDS[0]} line
699+
local cmd=${COMP_WORDS[0]} func line
700700
read line <<<"$($cmd --version)"
701701
case "$line" in
702702
*GNU*)
703-
_gtar "$@"
703+
func=_gtar
704704
;;
705705
*)
706-
_posix_tar "$@"
706+
func=_posix_tar
707707
;;
708708
esac
709+
$func "$@"
710+
711+
# Install real completion for subsequent completions
712+
if [ -n "${COMP_TAR_INTERNAL_PATHS:-}" ]; then
713+
complete -F $func -o dirnames tar
714+
else
715+
complete -F $func tar
716+
fi
717+
unset -f _tar
709718
}
710719

711720

0 commit comments

Comments
 (0)