source | all docs for version 0.7.pre8 | all versions | oilshell.org
Warning: Work in progress! Leave feedback on Zulip or Github if you'd like this doc to be updated.
echo $stringfunc(x, y)
NOTE: "__$stringfunc(x, y)__"
doesn't work. Do this instead:
var s = stringfunc(x, y)
echo "__$s__"
cc -o foo -- @arrayfunc(x, y)
@array
Conclusion: I think the conservative approach is better.
This is the same discussion as $f(x) vs
$(f(x))` on the inline function calls thread.
We only want to interpolate vars and functions. Arbitrary expressions aren't necessary.
In summary:
echo foo=$x
interpolates a variable into a unquoted wordecho foo=$f(x)
interpolates a call returning a string into an unquoted wordecho "foo=$[x] 1 2 3"
interpolates a variable into a double quoted stringecho "foo=${x} 1 2 3"
-- older, sameecho "foo=$[f(x)] 1 2 3"
interpolates a call returning a string into a double quoted stringOK I'm pretty happy with this explanation! Shell is messy but Oil is bringing some order to it :)
And then for completeness we also have:
echo @x
interpolates an array into a commandecho @f(x)
interpolates a function returning an array into a command${x|html}
${x %.3f}