1
0
mirror of https://git.tukaani.org/xz.git synced 2026-10-31 03:14:56 +00:00

xzdiff: Fix the one-operand case with the _z suffix

The _z suffix was accepted when only one file was given, but the expr
that removes the suffix requires a - or . before it. FILE became empty:

$ xzdiff foo_z
diff: '': No such file or directory

Link: https://github.com/tukaani-project/xz/pull/258
This commit is contained in:
Ali Ahmet Memiş 2026-10-24 21:57:29 +03:00 committed by Lasse Collin
parent 5a0dbb19c6
commit 1b1a508859
No known key found for this signature in database
GPG Key ID: 38EE757D69184620

View File

@ -95,8 +95,10 @@ if test $# -eq 1; then
# The FILE variable is used with eval, and shellcheck doesn't see that.
# shellcheck disable=SC2034
case $1 in
*[-.][zZ] | *_z | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *[-.]lz | *[-.]lzo | *[-.]zst | *[-.]lz4)
*[-.][zZ] | *[-.][gx]z | *[-.]bz2 | *[-.]lzma | *[-.]lz | *[-.]lzo | *[-.]zst | *[-.]lz4)
FILE=`LC_ALL=C expr "X$1" : 'X\(.*\)[-.][abglmostxzZ24]*$'`;;
*_z)
FILE=`LC_ALL=C expr "X$1" : 'X\(.*\)_z$'`;;
*.t[abglx]z)
FILE=`LC_ALL=C expr "X$1" : 'X\(.*[-.]t\)[abglx]z$'`ar;;
*.tbz2)