0

Is there a way to test when a variable name is not in use?

I am currently doing this:

#!/usr/bin/fish

set -l options (fish_opt -s n)
argparse $options -- $argv

if set --query _flag_n
else
    # Run some code only if -n is not set.
end

$_flag_n will likely be empty, so I can't check against string length.

rideron89
  • 491
  • 3
  • 14
  • This question has been answered several time and is well documented in many websites [including SO](https://stackoverflow.com/questions/47743015/fish-shell-how-to-check-if-a-variable-is-set-empty), – Asya Corbeau Aug 14 '20 at 15:03
  • Thanks for the link. I had seen that question and tried to use the answer but couldn't get it working. I must have been doing something dumb. In my case I need to use `test -z "$_flag_n"` – rideron89 Aug 14 '20 at 15:21

0 Answers0