Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • Your question isn't clear. POSIX does define $(…), but only if evaluates to a nonnegative ineteger. Are you asking why the value of an expression consisting of an undefined variable is left unspecified? (That's what you seem to be asking, but then what does the $ operator have to do with it?) Commented Jan 6, 2016 at 23:16
  • 1
    @Gilles: POSIX said that Field variables shall be designated by a '$' followed by a number or numerical expression. The effect of the field number expression evaluating to anything other than a non-negative integer is unspecified; uninitialized variables or string values need not be converted to numeric values in this context. Then the expression follow $ need not be converted to numeric values, it means $(expression) unspecified, doesn't it? Commented Jan 7, 2016 at 1:34
  • @Gilles: And also, if expression was evaluated in numeric context, then the result must be a number. Here the expression follow $ wasn't defined to have numeric or string context, that's how $ operator affect. Commented Jan 7, 2016 at 1:42