mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC3063 (markdown)
26
SC3063.md
Normal file
26
SC3063.md
Normal file
@@ -0,0 +1,26 @@
|
||||
## In POSIX sh, test -R and namerefs in general are undefined.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
```sh
|
||||
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
|
||||
|
||||
### Related resources:
|
||||
|
||||
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user