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

(bash) Nested strings are not parsed correctly #2099

Closed
2 tasks done
behrangsa opened this issue Aug 10, 2019 · 2 comments · Fixed by #2439
Closed
2 tasks done

(bash) Nested strings are not parsed correctly #2099

behrangsa opened this issue Aug 10, 2019 · 2 comments · Fixed by #2439
Labels
bug help welcome Could use help from community language

Comments

@behrangsa
Copy link

behrangsa commented Aug 10, 2019

Example:

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
TLS_DIR="$SCRIPT_DIR/../src/main/resources/tls"
ROOT_DIR="$SCRIPT_DIR/.."

This is really two things.

@joshgoebel
Copy link
Member

joshgoebel commented Oct 4, 2019

Bash syntax currently only supports simple variables inside $() blocks in strings:

  };
  var QUOTE_STRING = {
    className: 'string',
    begin: /"/, end: /"/,
    contains: [
      hljs.BACKSLASH_ESCAPE,
      VAR,
      {
        className: 'variable',
        begin: /\$\(/, end: /\)/,
        contains: [hljs.BACKSLASH_ESCAPE]
      }
    ]
  };

To fix this you'd have to make bash self-referential (ie you can have bash inside bash)... I'm not sure that's possible (but need to learn).

Evidently technically this is possible since Ruby does it - if you'd be willing to work on a PR?

@joshgoebel
Copy link
Member

This also applies to simple variables without variables (same issue really from #1978):

In a bash script, you may have a variable WURST und refer to it via $WURST or ${WURST}.
You can supply a default value ${WURST:-salami} and that default value may itself be a variable
${WURST:-${CARNE}}. And this is where there's a bug in highlight.js:
In the last example, of the two closing curly braces at the end only the first one gets color, the latter one doesn't -- although it should because it is the closing brace to the very first opening curly brace.

@joshgoebel joshgoebel added bug help welcome Could use help from community labels Oct 7, 2019
@joshgoebel joshgoebel changed the title Nested strings in bash are not parsed correctly (bash) Nested strings are not parsed correctly Oct 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug help welcome Could use help from community language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants