1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-29 11:21:22 +03:00

Imply -q when stderr is not a tty (#2884)

* Imply -q when stderr is not a tty
This commit is contained in:
binhdvo
2021-12-07 16:56:19 -05:00
committed by GitHub
parent b6b4c9a3da
commit 38dfc4699e
2 changed files with 7 additions and 7 deletions

View File

@ -1402,7 +1402,7 @@ int main(int argCount, const char* argv[])
/* No status message in pipe mode (stdin - stdout) */ /* No status message in pipe mode (stdin - stdout) */
hasStdout = outFileName && !strcmp(outFileName,stdoutmark); hasStdout = outFileName && !strcmp(outFileName,stdoutmark);
if (hasStdout && (g_displayLevel==2)) g_displayLevel=1; if ((hasStdout || !IS_CONSOLE(stderr)) && (g_displayLevel==2)) g_displayLevel=1;
/* IO Stream/File */ /* IO Stream/File */
FIO_setHasStdoutOutput(fCtx, hasStdout); FIO_setHasStdoutOutput(fCtx, hasStdout);

View File

@ -351,8 +351,8 @@ zstd < tmpPrompt -o tmpPrompt.zst -f # should successfully overwrite with -f
zstd -q -d -f tmpPrompt.zst -o tmpPromptRegenerated zstd -q -d -f tmpPrompt.zst -o tmpPromptRegenerated
$DIFF tmpPromptRegenerated tmpPrompt # the first 'y' character should not be swallowed $DIFF tmpPromptRegenerated tmpPrompt # the first 'y' character should not be swallowed
echo 'yes' | zstd tmpPrompt -o tmpPrompt.zst # accept piped "y" input to force overwrite when using files echo 'yes' | zstd tmpPrompt -v -o tmpPrompt.zst # accept piped "y" input to force overwrite when using files
echo 'yes' | zstd < tmpPrompt -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite" echo 'yes' | zstd < tmpPrompt -v -o tmpPrompt.zst && die "should have aborted immediately and failed to overwrite"
zstd tmpPrompt - < tmpPrompt -o tmpPromp.zst --rm && die "should have aborted immediately and failed to remove" zstd tmpPrompt - < tmpPrompt -o tmpPromp.zst --rm && die "should have aborted immediately and failed to remove"
println "Test completed" println "Test completed"
@ -371,9 +371,9 @@ test ! -f tmp.zst # tmp.zst should no longer be present
println "test : should quietly not remove non-regular file" println "test : should quietly not remove non-regular file"
println hello > tmp println hello > tmp
zstd tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID" zstd tmp -f -o "$DEVDEVICE" 2>tmplog > "$INTOVOID"
grep -v "Refusing to remove non-regular file" tmplog grep "Refusing to remove non-regular file" tmplog && die
rm -f tmplog rm -f tmplog
zstd tmp -f -o "$INTOVOID" 2>&1 | grep -v "Refusing to remove non-regular file" zstd tmp -f -o "$INTOVOID" 2>&1 | grep "Refusing to remove non-regular file" && die
println "test : --rm on stdin" println "test : --rm on stdin"
println a | zstd --rm > $INTOVOID # --rm should remain silent println a | zstd --rm > $INTOVOID # --rm should remain silent
rm -f tmp rm -f tmp
@ -420,11 +420,11 @@ zstd tmp1 tmp2 -q -o tmpexists && die "should have refused to overwrite"
println gooder > tmp_rm1 println gooder > tmp_rm1
println boi > tmp_rm2 println boi > tmp_rm2
println worldly > tmp_rm3 println worldly > tmp_rm3
echo 'y' | zstd tmp_rm1 tmp_rm2 -o tmp_rm3.zst --rm # tests the warning prompt for --rm with multiple inputs into once source echo 'y' | zstd tmp_rm1 tmp_rm2 -v -o tmp_rm3.zst --rm # tests the warning prompt for --rm with multiple inputs into once source
test ! -f tmp_rm1 test ! -f tmp_rm1
test ! -f tmp_rm2 test ! -f tmp_rm2
cp tmp_rm3.zst tmp_rm4.zst cp tmp_rm3.zst tmp_rm4.zst
echo 'Y' | zstd -d tmp_rm3.zst tmp_rm4.zst -o tmp_rm_out --rm echo 'Y' | zstd -d tmp_rm3.zst tmp_rm4.zst -v -o tmp_rm_out --rm
test ! -f tmp_rm3.zst test ! -f tmp_rm3.zst
test ! -f tmp_rm4.zst test ! -f tmp_rm4.zst
echo 'yes' | zstd tmp_rm_out tmp_rm3 -c --rm && die "compressing multiple files to stdout with --rm should fail unless -f is specified" echo 'yes' | zstd tmp_rm_out tmp_rm3 -c --rm && die "compressing multiple files to stdout with --rm should fail unless -f is specified"