|
From: | Florian Mayer |
Subject: | Re: Curious case of arithmetic expansion |
Date: | Sun, 23 Apr 2017 15:50:13 +0200 |
Give out an error message hopefully (and it does), because the _expression_ (bar+14+moo*2)++ makes no semantical sense in terms of arithmetic expressions the bash uses, because ++ only can apply to locations and (bar+14+moo*2) evaluates to a number no matter the contents of bar and moo… So lets assume that bash only executes things like ((<exp>++)) if and only if <exp> is a proper location (that is a string that is no number). We know that in this case only two things can happen. (1) <exp> refers directly to a number value or (2) <exp> refers to another string that is a location In case of (1) the result is obvious. In case of (2) my complain applies.
I wouldn’t consider this a special case, because the syntax and semantics are almost identical to those of C (with the exception of the numerous exceptions like recursive expansions etc.). So bash should also implement the same lvalue, rvalue semantics that C does. Of course, with the appropriate adjustments needed to fit in the context of a string typed command line interpreter :) Mhh…
Thank you.
|
[Prev in Thread] | Current Thread | [Next in Thread] |