On Thu, Aug 20, 2026 at 10:43:10 +0700, Robert Elz wrote:

> +     if (command printf "" > /etc/rcorder.cache.tmp) 2>/dev/null; then
> 
> Here you don't need the 'command printf ""' at all, this is just
> testing whether the file can be opened for writing, and creating it,
> though that isn't essential, and for that 
> 
> +     if (> /etc/rcorder.cache.tmp) 2>/dev/null; then
> 
> would work just fine.   Unfortunately I think the () (subshell) is
> needed, as redirection errors in scripts tend to cause the shell to
> exit ... the subshell exiting is harmless, it had no more work to
> do anyway, but the shell running the script can't be allowed to
> just exit there.

I thought that would be determined by whether the command we redirect
is a "special built-in utility".

https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_08_01

So : > ... would cause the shell to exit on failure, b/c ":" is a
speciale built-in, but a bare redirection probably doesn't (but I
don't have time to find chapter and verse for that at the moment,
unfortunately).  Hence, the "command" in the original, I guess, to
take the edge off :) (I learned it from dealing with nowadays
ubiquitous set -o pipefail in scripts that causes the shell to exit if
it doesn't know pipefail).

-uwe

Reply via email to