On Fri, Oct 20, 2000 at 06:22:04PM +0200, Bernard Dautrevaux wrote:
: > test s${CONFIG_FILES+et} = set || CONFIG_FILES=$config_files
: 
: Hi all,
: 
: I usually use the following construct, to protect against any kind of value
: for FOO, be it empty or starting with a special character:
: 
: test X"${FOO+set}" = X"set" || FOO=$foo

I can appreciate having fixed conventions for things like this, and I
usually do quote on both sides of the =.

Anyways, what would be really cool is to find a LHS expansion that would
either expand to "set" or to "unset" depending on whether the variable was
set or not.  I haven't been able to think of one, though.  Does anyone
know it that could be done?

This trick is kind of cool, but it's the inverse of what I originally
looked for:

if test ${VAR+un}set != unset; then
  # VAR is set
fi

and

if test ${VAR+un}set != set; then
  # VAR is unset
fi

  Lars J

Reply via email to