Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax highlight error on quotes inside $(( )) #336

Open
mozirilla213 opened this issue Jun 24, 2023 · 2 comments
Open

Syntax highlight error on quotes inside $(( )) #336

mozirilla213 opened this issue Jun 24, 2023 · 2 comments

Comments

@mozirilla213
Copy link

GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) [Arch Linux]
ble.sh, version 0.4.0-devel4+0906fd95 (noarch) [git 2.40.1, GNU Make 4.4.1, GNU Awk 5.2.2, API 3.2, PMA Avon 8-g1, (GNU MPFR 4.2.0-p9, GNU MP 6.2.1)]
bash-completion, version 2.11 (hash:2d02f73e803daa87a06e94e33b2a7b3e672a2c0c, 76338 bytes) (noarch)
locale: LANG=C
terminal: TERM=xterm-256color wcwidth=15.0-west/13.0-2+ri, konsole:220380 (1;115;0)

The first double quote inside $(( )), not (( )) is highlighted as syntax error

echo $(("$1" + "$2"))
#       ↑      ↑

or both quotes in these:

echo $(("10" + 20))
echo $((`echo 10` "+" 20))
@akinomyoga
Copy link
Owner

akinomyoga commented Jun 29, 2023

Thanks for the report. Originally the check for the quoting in the arithmetic context was implemented for Bash 4.3. However, the behavior of Bash seems to have changed. After your report, I have made comprehensive tests for quoting in the arithmetic context. Here are the behavioral differences of different quoting between different contexts and Bash versions, where the check mark indicates that the quoting is supported:

COMMAND 3.0..4.3 4.4..5.0 5.1 5.2..dev
echo $((\10))
echo $(('10'))
echo $(($'10'))
echo $(("10"))
echo $(($"10"))
echo $((a[\10]))
echo $((a["10"]))
echo $((`echo 10`))
echo $[\10]
echo $['10']
echo $[$'10']
echo $["10"]
echo $[$"10"]
echo $[a[\10]]
echo $[a["10"]]
echo $[`echo 10`]
((\10))
(('10'))
(($'10'))
(("10"))
(($"10"))
((a[\10]))
((a["10"]))
((`echo 10`))
b[\10]=
b['10']=
b[$'10']=
b["10"]=
b[$"10"]=
b[a[\10]]=
b[a["10"]]=
b[`echo 10`]=
: ${b[\10]}
: ${b['10']}
: ${b[$'10']}
: ${b["10"]}
: ${b[$"10"]}
: ${b[a[\10]]}
: ${b[a["10"]]}
: ${b[`echo 10`]}
b=([\10]=)
b=(['10']=)
b=([$'10']=)
b=(["10"]=)
b=([$"10"]=)
b=([a[\10]]=)
b=([a["10"]]=)
b=([`echo 10`]=)
: ${v:\10}
: ${v:'10'}
: ${v:$'10'}
: ${v:"10"}
: ${v:$"10"}
: ${v:a[\10]}
: ${v:a["10"]}
: ${v:`echo 10`}
: "${v:\10}"
: "${v:'10'}"
: "${v:$'10'}"
: "${v:"10"}"
: "${v:$"10"}"
: "${v:a[\10]}"
: "${v:a["10"]}"
: "${v:`echo 10`}"

The behavior also depends on shopt -s extquote.

@akinomyoga
Copy link
Owner

akinomyoga commented Jun 29, 2023

I've supported the Bash-version dependent checking in commit 611c1d9. (For a few contexts, I gave up a perfect implementation for older versions of Bash.) Could you update ble.sh by running the command ble-update and check the behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants