cursorless icon indicating copy to clipboard operation
cursorless copied to clipboard

Fix strings in bash

Open pokey opened this issue 1 year ago • 4 comments

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 avatar Jul 26 '24 14:07 pokey

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

pokey avatar Jul 26 '24 14:07 pokey

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)
        )
        ")"
      )
      """
    )
  )
)

AndreasArvidsson avatar Jul 28 '24 08:07 AndreasArvidsson

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

pokey avatar Jul 28 '24 08:07 pokey

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

pokey avatar Jul 28 '24 08:07 pokey