conditional-operator

Bash -R — nameref attribute

Tests whether the named variable has the nameref attribute; it does not check that the target is set. This is a Bash-specific predicate; the example uses Bash 5.2 and trusted fixed names. Run the example independently in a fresh private directory. Expected output (one item per line): reference=0; plain=1.

Formal Syntax & Structure

bash syntaxbash
[[ -R name ]]

Parameters & Attributes

NameTypeDescription
namevariable nameTrusted shell variable name, not its expanded value.

Return Value

exit status

0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.

Working Example

Example Snippetbash
unset targetdeclare -n ref=targetplain=target[[ -R ref ]]; printf 'reference=%s\n' "$?"[[ -R plain ]]; printf 'plain=%s\n' "$?"
Bash Reference