varnish-cache icon indicating copy to clipboard operation
varnish-cache copied to clipboard

`varnishadm` always returns 0 (success) when commands sent via STDIN

Open Bilge opened this issue 2 years ago • 1 comments

Expected Behavior

varnishadm returns a non-zero exit code when any command sent via STDIN fails.

Current Behavior

Regardless of how many commands are sent to varnishadm and whether any of them fail or not, it always returns a zero (success) code.

Possible Solution

Whenever any command fails in a series of commands sent to varnishadm, the program stops at that point. The exit code of that command should be used when the main process exits.

Steps to Reproduce (for bugs)

varnishadm vcl.load x; echo $?

1

echo vcl.load x | varnishadm; echo $?

0

Context

See varnishcache/pkg-varnish-cache#170.

Varnish Cache version

varnishd (varnish-6.6.1 revision e6a8c860944c4f6a7e1af9f40674ea78bbdcdc66)

Operating system

Ubuntu 22.04.3 LTS

Source of binary packages used (if any)

http://nova.clouds.archive.ubuntu.com/ubuntu

Bilge avatar Oct 21 '23 20:10 Bilge

This is not optimal.

The problem is you dont want varnishadm to give up in interactive mode.

Bugwash consensus:

Give varnishadm -e argument (like shells) which makes it stop in first bad return, but with the same - prefix feature as varnishd -I

bsdphk avatar Oct 23 '23 13:10 bsdphk