mirror of
https://github.com/facebook/zstd.git
synced 2025-04-20 12:07:47 +03:00
Fixes #3211. Adds the `--[no-]pass-through` flag which enables/disables pass-through mode. * `zstdcat`, `zcat`, and `gzcat` default to `--pass-through`. Pass-through mode can be disabled by passing `--no-pass-through`. * All other binaries default to not setting pass-through mode. However, we preserve the legacy behavior of enabling pass-through mode when writing to stdout with `-f` set, unless pass-through mode is explicitly disabled with `--no-pass-through`. Adds a new test for this behavior that should codify the behavior we want.
58 lines
1.4 KiB
Bash
Executable File
58 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
. "$COMMON/platform.sh"
|
|
|
|
echo "" > 1
|
|
echo "2" > 2
|
|
echo "23" > 3
|
|
echo "234" > 4
|
|
echo "some data" > file
|
|
|
|
println "+ passthrough enabled"
|
|
|
|
zstd file
|
|
|
|
# Test short files
|
|
zstd -dc --pass-through 1 2 3 4
|
|
|
|
# Test *cat symlinks
|
|
zstdcat file
|
|
"$ZSTD_SYMLINK_DIR/zcat" file
|
|
"$ZSTD_SYMLINK_DIR/gzcat" file
|
|
|
|
# Test multiple files with mix of compressed & not
|
|
zstdcat file file.zst
|
|
zstdcat file.zst file
|
|
|
|
# Test --pass-through
|
|
zstd -dc --pass-through file
|
|
zstd -d --pass-through file -o pass-through-file
|
|
|
|
# Test legacy implicit passthrough with -fc
|
|
zstd -dcf file
|
|
zstd -dcf file file.zst
|
|
zstd -df < file
|
|
zstd -dcf < file file.zst -
|
|
zstd -dcf < file.zst file -
|
|
|
|
$DIFF file pass-through-file
|
|
|
|
println "+ passthrough disabled"
|
|
|
|
# Test *cat
|
|
zstdcat --no-pass-through file && die "should fail"
|
|
"$ZSTD_SYMLINK_DIR/zcat" --no-pass-through file && die "should fail"
|
|
"$ZSTD_SYMLINK_DIR/gzcat" --no-pass-through file && die "should fail"
|
|
# Test zstd without implicit passthrough
|
|
zstd -d file -o no-pass-through-file && die "should fail"
|
|
zstd -d < file && die "should fail"
|
|
|
|
# Test legacy implicit passthrough with -fc
|
|
zstd --no-pass-through -dcf file && die "should fail"
|
|
zstd --no-pass-through -dcf file file.zst && die "should fail"
|
|
zstd --no-pass-through -df < file && die "should fail"
|
|
zstd --no-pass-through -dcf < file file.zst - && die "should fail"
|
|
zstd --no-pass-through -dcf < file.zst file - && die "should fail" ||:
|