[Why `if test "x$var" = x; then`?] At 2025-11-18T16:31:44-0600, G. Branden Robinson wrote: > Consider... > > test "$var" = "whatever" > > ...when the value of var is "-n" or "-z", for instance. If the shell > performs quote removal "too early", it's likely to pass incorrect > arguments to test(1). > > Fortunately, every shell on my Debian box does NOT have this problem. [...] > Perhaps it is impossible to avoid if "test"/"[" is not a shell > builtin? Do any shells of that description still live?
It pains me to say this, but... This being the coreutils mailing list, possibly documentation of GNU test/[ should advise usage of the "x$var" = "x" idiom if the coreutils test/[ is being used on purpose. By the time any shell has built an external test/['s argv[], any quotation will have been lost. If this ugliness can't be abandoned at last, it is best that we advise users only to employ it where absolutely necessary. Regards, Branden
signature.asc
Description: PGP signature
