2019-07-29 17:55:58 +0100, Isabella Bosia:
> haven't really looked into why this happens but x[ seems to trigger some
> funny parser behavior
> 
> x[ newline     should not prompt with PS2
> 
> it can't be defined as a normal sh function, but it can be defined with the
> function keyword
[...]

x[ is the start of an array element assignment. newline is valid (just a token
separator like space) inside an arithmetic expression.

$ x[
> 1
> +
> 1
> ]=3
$ typeset -p x
declare -a x=([2]="3")

You'll notice:

$ +[
+[: command not found
$ 'x'[
x[: command not found

-- 
Stephane

Reply via email to