On Sat, Nov 26, 2022 at 10:09:22AM +0700, Robert Elz wrote:
> My preferred method for this, which works for all kinds
> of variables and parameters is
> 
>       test "${X+s}" = s
> 
> where X is whatever is to be tested (1 in this case)
> and "s" is any string you like, except "" .. must be
> the same both occurrences of course.

This is also recommended on <https://mywiki.wooledge.org/BashFAQ/083>
for the general case.

I don't personally suggest using it to check how many positional
parameters were given, because there are alternatives that are much
easier to read for that case.

Reply via email to