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

Shell script syntax highlighting fails with indented EOT HereDoc #223443

Closed
sandy-fairsupply opened this issue Jul 24, 2024 · 1 comment
Closed
Assignees
Labels
grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream

Comments

@sandy-fairsupply
Copy link

sandy-fairsupply commented Jul 24, 2024

Type: Bug

POSIX shell scripts that use an indented EOT marker break syntax highlighting for the remainder of the file. In the following shell script:

  • The last two lines ) and echo "$foo" appear to be part of the HereDoc, but they should not be
  • The opening paren ( is marked as an error (unmatched), but it should not be.
#!/bin/sh
foo=$(cat <<'    EOT'
        A HereDoc
    EOT
)
echo "$foo"

Screenshot showing the incorrect highlighting:

image

In both Bash and Dash, the script runs without error and outputs A HereDoc\n as expected.

Related issue: #77675. That issue was closed by PR #169118, which adopted a different grammar. Technically this issue is a duplicate, but the original problem was not fixed; indeed @jeff-hykin said "#77675 (code example at top of this issue) is not [fixed]".

Note that in POSIX, Bash's indented HereDoc syntax <<-'EOT' in not available.

VS Code version: Code 1.91.1 (Universal) (f1e16e1, 2024-07-09T22:07:54.982Z)
OS version: Darwin arm64 23.5.0
Modes:

System Info
Item Value
CPUs Apple M2 (8 x 2400)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) 5, 3, 4
Memory (System) 24.00GB (1.84GB free)
Process Argv --disable-extensions --crash-reporter-id 71395059-61c9-412b-873d-3c471fa4f758
Screen Reader no
VM 0%
Extensions disabled
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonnoceb:30805159
asynctok:30898717
pythonregdiag2:30936856
pythonmypyd1:30879173
2e7ec940:31000449
pythontbext0:30879054
accentitlementsc:30995553
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
dsvsc021:30996838
724cj586:31013169
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
dwnewjupyter:31046869
impr_priority:31094925
refactorc:31101458
ccplti:31098112

@alexr00
Copy link
Member

alexr00 commented Jul 29, 2024

Thanks for all the details! Moved to jeff-hykin/better-shell-syntax#97.

@alexr00 alexr00 closed this as completed Jul 29, 2024
@alexr00 alexr00 added grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream labels Jul 29, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Sep 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
grammar Syntax highlighting grammar upstream-issue-linked This is an upstream issue that has been reported upstream
Projects
None yet
Development

No branches or pull requests

2 participants