Skip to content

Highlight parameter expansions : $foo #739

@mirsella

Description

@mirsella

Environnement variable are not highlighted, example echo $foo $bar $foo and $bar are white.
i think a line in tweak main would be appropriated.
example :
ZSH_HIGHLIGHT_STYLES[variable] if the variable exist et is not empty.
ZSH_HIGHLIGHT_STYLES[variable-empty] if the variable is not set or is empty.

i have posted this comment on another thread, tell me if it's better if i delete it to clean the thread.

thanks

Activity

danielshahaf

danielshahaf commented on May 26, 2020

@danielshahaf
Member

Copying your previous comment for context:

sorry if it's the wrong place to ask. my variable $foo $bar are not highlighted, and i see no option to enable/change it in the tweak section.
i mean a option :
if the variable exist ZSH_HIGHLIGHT_STYLES[variable] for example and ZSH_HIGHLIGHT_STYLES[variable-unset] if the variable doesn't exist.
there those in the tweak page :

comment - comments, when setopt INTERACTIVE_COMMENTS is in effect (echo # foo)
comment - elided parameters in command position ($x ls when $x is unset or empty)

but both referenced by using "comment". is it a typo or i misunderstood ? seems like the second one is what i was looking for.
it's preferable that i create a new issue ? i didn't find one related. thanks

tell me if you prefer that I delete this message to clean up the thread. I'll do the issue tomorrow as it's already late where I live


i have posted this comment on another thread, tell me if it's better if i delete it to clean the thread.

Thanks, but I'll do that myself since I need to delete my own comment too.

danielshahaf

danielshahaf commented on May 26, 2020

@danielshahaf
Member

In echo $foo, the parameter expansion «$foo» can result in one of three different behaviours:

  1. Variable will be expanded. (when $foo is set and not empty)
  2. Variable will be elided. (when $foo is either set to empty, or unset and the UNSET option is at its default value)
  3. A runtime error will be reported. (when $foo is unset and the UNSET option is unset [i.e., set -u is in effect])

If I understand correctly, @mirsella, you are asking for the $foo in cases (1) and (2) to be highlighted (differently in each case). Is that correct?

I think there are existing issues for all of these: #509 [which I have just retitled] for (1), #718 for (2), #450 for (3), and #484 and #485 for some extra functionality. Accordingly, I'm inclined to close these issue as a duplicate of those other ones — unless there's some request here that's not covered by those other issues? If so, what is it?

changed the title [-][ Feature Request ] Support environnement variable highlighting : $foo[/-] [+]Highlight parameter expansions : $foo[/+] on May 26, 2020
danielshahaf

danielshahaf commented on May 26, 2020

@danielshahaf
Member

(I've retitled the issue since it's not specifically about environment variables but about parameter expansions in general.)

mirsella

mirsella commented on May 26, 2020

@mirsella
Author

thanks for the complete answer. sorry for my english

If I understand correctly, @mirsella, you are asking for the $foo in cases (1) and (2) to be highlighted (differently in each case). Is that correct?

that precisely it.
i didn't found all of the issue you linked when i searched, it would have prevented this useless issue.
you can close this issue if you want since all of those issue you linked are separated part of my issue.

danielshahaf

danielshahaf commented on May 26, 2020

@danielshahaf
Member

Thanks, closing. (You can subscribe to the other issues, of course.) In this case, finding other issues would have been not as straightforward as usual, because these are commonly known as "variables" but the zsh syntax documentation terms them "parameters" instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @danielshahaf@mirsella

        Issue actions

          Highlight parameter expansions : $foo · Issue #739 · zsh-users/zsh-syntax-highlighting