[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] context sensitive parameter expansion
From: |
Peng Yu |
Subject: |
[Help-bash] context sensitive parameter expansion |
Date: |
Thu, 14 Feb 2019 22:39:01 -0600 |
I have some questions about the design of parameter expansion syntax.
$ echo ${x/a/\"}
"bc
$ echo ${x/a/"}
> ^C
Since " is not used here, why it should be escaped. Based on the
context ${}, it should be clear a double quote should mean a double
quote literally. Wouldn't it be better if " does not have to be
escapped?
$ echo ${x/a/\}}
}bc
This is legitimate, as if } is not escapped, it is not clear whether
it means the end of the parameter expansion.
$ echo ${x/a/\/}
/bc
$ echo ${x/a//}
/bc
Why the last slash is allowed to be escaped (which is equivalent to be
non escaped)? Since there is no point to escape it, isn't that a
syntax error would be better?
$ echo ${x/a/\\}
\bc
--
Regards,
Peng
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-bash] context sensitive parameter expansion,
Peng Yu <=