cursorless-dev / cursorless

Don't let the cursor slow you down
https://www.cursorless.org/
MIT License
1.14k stars 79 forks source link

Fix strings in bash #2586

Open pokey opened 2 months ago

pokey commented 2 months ago

In bash, we don't properly support strings. For example:

commit_message="$(git log -1 --pretty=format:"%s" HEAD)"

This is actually two nested strings: "$(git log -1 --pretty=format:"%s" HEAD)" and "%s". Instead we treat it as two strings in sequence: "$(git log -1 --pretty=format:" and " HEAD)". We should figure out how to make this work, probably using the parse tree, and/or some flavour of https://github.com/cursorless-dev/cursorless/issues/1812#issuecomment-1691493746

pokey commented 2 months ago

@AndreasArvidsson fyi this doesn't work either on today's main or on https://github.com/cursorless-dev/cursorless/pull/2457

AndreasArvidsson commented 2 months ago

This is one of those things we probably need to use the parse tree

(program
  (variable_assignment
    name: (variable_name)
    "="
    value: (string
      """
      (command_substitution
        "$("
        (command
          name: (command_name
            (word)
          )
          argument: (word)
          argument: (number)
          argument: (concatenation
            (word)
            (string
              """
              (string_content)
              """
            )
          )
          argument: (word)
        )
        ")"
      )
      """
    )
  )
)
pokey commented 2 months ago

I think we could just use parse tree to tell us if it's opening or closing?

pokey commented 2 months ago

Text fragment thing will get in the way a bit tho I fear as well treat the string as a fragment