Bash -o -v -R operators

I do not know the use of the -o -v -R operators.

This is what the info says and I am confused of what optname and varname
mean, are they just normal variable?

       -o optname
              True if the shell option optname is enabled.  See  the  list  of
              options  under  the  description  of  the  -o  option to the set
              builtin below.
       -v varname
              True if the shell variable varname is set (has been  assigned  a
              value).
       -R varname
              True  if  the shell variable varname is set and is a name refer
              ence.

I think you are looking at the help for set . They change the behavior of bash.
Here is a better chunk - note that options for set show up via different options.
These settings control bash's behavior. They are not ordinary variables.
Example: -x turns on a kind of running debug display, great for fixing problems, but not for production code.

For starters try: try

echo "$-"

the variable that displays these settings.

They are in the section Conditional Expressions when I do info bash.
How can one use them. I have tried searching around but have not found examples.

You're right - those are "unary primaries" to be used in "Conditional Expressions". man bash :

Use like

[ -v var ]  && echo "var set" || echo Nope

or in a corresponding if construct.

Using the following I am getting bash to complain by saying

../../../../siculet/amvib/day-sort.sh: line 152: syntax error near unexpected token `fi'
../../../../siculet/amvib/day-sort.sh: line 152: `fi'
if [ -v opt_day ] || [ -v opt_default ]; then
  sort_by_day $val_dir
elif
  sort_by_station $val_dir
fi

How about testing / checking / verifying what you learned in small steps, e.g. by running the small snippet posted? And then only proceeding to a more complex example?

For your above problem (totally different story!): elif needs an additional test and a then keyword... c.f. man bash .

I have tried the example and now need to use in an if condition. Do not understand how I need an additional test and a then keyword. How does that work out?

---------- Post updated at 02:49 PM ---------- Previous update was at 02:43 PM ----------

I understand now

---------- Post updated at 03:56 PM ---------- Previous update was at 02:49 PM ----------

How about -o optname? What is a shell option optname

And for -R optname, what is a name reference?