1

I noticed that bash will correctly apply syntax highlighting inside the subshell substitution in

VALUE="Hello $(echo World)."

But when creating a more complicated value, e.g.

VALUE="Hello $(
    echo good
    echo world
)."

the commands inside the subshell will be highlighted as string-contents, and indentation will behave as text-mode indentation. Indentation works correctly when writing something like

VALUE="Hello "$(
    echo good
    echo world
)"."

but this changes the semantics, unless IFS is set to the empty string.

Is there some way to fix this?

  • 1
    Not sure what you mean by "correctly apply code". AFAIK it only highlights the echo right after $( but doesn't find the sed in "foo $(echo toto | sed titi)". I think this "feature"'s implementation is very naive and would need to be completely rewritten. As for indentation, it's a completely separate question. I suggest you file those two issues as feature requests via M-x report-emacs-bug. – Stefan Aug 31 at 16:21
  • @Stefan Fixed the wording from "code" to "syntax highlighting". – kdb Sep 2 at 7:42
  • 1
    Seems the implementation assumes, that "quoted exec" ("`cmd`", "$(cmd)") always consist of a single command only. Easiest way to avoid the issues, seems to be writing scripts with IFS=''... – kdb Sep 2 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.