Closed jobace78 closed 6 months ago
If I understand the docs correctly, the LHS does not need quotes (but I may be mistaken). https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#index-_005b_005b says
The words between the [[ and ]] do not undergo word splitting and filename expansion.
Please note that the old-style test command [
needs quoting, because it's not a built-in:
#!/usr/bin/env bash
lhs="a b c"
[[ $lhs =~ ^[\ a-z]+$ ]] && echo match
[ "$lhs" == "a b c" ] && echo match
AFAIK shfmt (which is used as formatter by BashSupport Pro) only makes the change you posted if option Settings > Code Style > BashSupport Pro > Simplify the code
is enabled. By default, this setting is turned off.
Do you have this setting enabled?
Hi,
I think you're right, there is no need to quote and also I have the simplify code option enabled.
Thank you :-)
Hi,
I'm trying BashSupport Pro (coming from bundled Shell Script plugin) and I found this behaviour:
The formatter changes this...
if [[ "${valid_response_http_codes}" =~ ${response_http_code:?} ]]; then
...to this...
if [[ ${valid_response_http_codes} =~ ${response_http_code:?} ]]; then
AFAIK the left side should be quoted, so, this is a bug or it is intended?
Thanks