From: Gabriel F. T. Gomes <gabriel@inconstante.eti.br>
Subject: tar: Support completions for zstd compression extensions
Origin: vendor, https://bugs.debian.org/913949
Bug-Debian: https://bugs.debian.org/913949
Forwarded: yes, https://github.com/scop/bash-completion/pull/255

Since upstream version 1.30.90, GNU tar supports zstd compression [1].
According to the same NEWS entry, the extensions for archive names are
`.zst' and `.tzst'.  This patch adds support for completing these
extensions.

This is the output of the completions after the patch:

  $ ls[ENTER]
  bla.gem.gz   bla.invalid.gz   bla.spkg.gz   bla.tar.gz   bla.tgz
  bla.gem.zst  bla.invalid.zst  bla.spkg.zst  bla.tar.zst  bla.tzst
  $ tar -tf bla.[TAB]
  bla.gem.gz    bla.spkg.gz   bla.tar.gz    bla.tgz
  bla.gem.zst   bla.spkg.zst  bla.tar.zst   bla.tzst
  $ tar -ztf bla.[TAB]
  bla.gem.gz   bla.spkg.gz  bla.tar.gz   bla.tgz

Since tar does not provide a one-character shortcut for zstd
compression, I wasn't able to filter only .zst files:

  $ tar --zstd -tf bla.[TAB]
  bla.gem.gz    bla.spkg.gz   bla.tar.gz    bla.tgz
  bla.gem.zst   bla.spkg.zst  bla.tar.zst   bla.tzst

The request came from Adam Borowski via a Debian bug [2].

[1] http://git.savannah.gnu.org/cgit/tar.git/commit/NEWS?id=688924d2a8e1cefb2a5c6c5e562391b5bcfadcb2

[2] https://bugs.debian.org/913949
---
 completions/tar | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/completions/tar b/completions/tar
index 49265ad4..f6983d50 100644
--- a/completions/tar
+++ b/completions/tar
@@ -433,9 +433,9 @@ __tar_cleanup_prev()
 
 __tar_detect_ext()
 {
-    local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)))|t@([abglx]z|b?(z)2))'
+    local tars='@(@(tar|gem|spkg)?(.@(Z|[bgx]z|bz2|lz?(ma|o)|zst))|t@([abglx]z|b?(z)2|zst))'
     ext="$tars"
-    regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\)\)\?\|t\([abglx]z\|bz\?2\)\)'
+    regex='\(\(tar\|gem\|spkg\)\(\.\(Z\|[bgx]z\|bz2\|lz\(ma\|o\)\?\|zst\)\)\?\|t\([abglx]z\|bz\?2\|zst\)\)'
 
     case "$tar_mode_arg" in
         --*)
-- 
2.19.1

