Clone
1
SC3063
Vidar Holen edited this page 2025-04-11 14:22:42 -07:00

In POSIX sh, test -R and namerefs in general are undefined.

Problematic code:

if [ -R foo ]
then
  ..
fi

Correct code:

POSIX sh has no concept of namerefs. Rewrite your logic to not depend on them, or switch to Bash or Ksh.

Rationale:

[ -R name ] is used to check whether name is a nameref. Since POSIX sh has no namerefs, either use a shell that does, or rewrite to not need namerefs.

Exceptions:

None

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!