Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

The shell syntax highlight is wrong after output redirection and a string #153

Open
1 task done
mzannoni opened this issue Oct 13, 2019 · 1 comment
Open
1 task done

Comments

@mzannoni
Copy link

Prerequisites

Description

The shell syntax highlighting does not behave as expected after the first double quote of a string that follows an output redirection (line 200 on the screenshot below).
All the rest of the file is somewhat coloured as a string (green).
Please find the following screenshot from Atom:
Atom_SafeMode_badShellSyntaxHighlight_Screenshot from 2019-10-13 22-19-42
For comparison, here's also a screenshot from gedit of the same file, to show how the syntax highlighting look:
gedit_goodShellSyntaxHihglight_Screenshot from 2019-10-13 22-21-31

(Copyright note: the code snippet shown in the screenshots above is from the script "multicrop" for ImageMagick by Fred Weinhaus, found at http://www.fmwconcepts.com/imagemagick/index.php)

After some trials, it seems that removing >&2 fixes the highlighting. So, the syntax is coloured correctly if that is deleted. In the steps below you find a snipped i used for trials.

Steps to Reproduce

  1. Take this snippet of code:
functs()
    {
    echo >&2 ""
    echo >&2 "$USER:" "$PATH"
    echo >&2 'this' "that"
    }
  1. Paste it in Atom, select "Shell Script" as sysntax highlighitng
  2. You'll see that after the first double quote of the first string after >&2 everything is green, a part from variables
  3. To verify what should be the behaviour, paste the same snippet in gedit and highlighting for "sh" does hold the desired result
  4. When the string >&2 is removed, sometimes the systax is highlighted correctly again.

Expected behavior:

See description

Actual behavior:

See description

Reproduces how often:

All the time, consistently

Versions

$ atom --version
Atom    : 1.40.1
Electron: 3.1.10
Chrome  : 66.0.3359.181
Node    : 10.2.0
$ apm --version
apm  2.4.3
npm  6.2.0
node 10.2.1 x64
atom 1.40.1
python 2.7.15+
git 2.17.1

Additional Information

Ubuntu OS, 18.04

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
@rsese rsese transferred this issue from atom/atom Oct 14, 2019
@rsese
Copy link

rsese commented Oct 14, 2019

Thanks for the report! Reproduced with 1.42.0-nightly8 on macOS 10.14.6 - with Tree-sitter:

shell-tree-sitter

With Tree-sitter disabled:

shell-textmate

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

No branches or pull requests

2 participants