Skip to content

set -l works outside of command block #8385

@EmilyGraceSeville7cf

Description

@EmilyGraceSeville7cf

Fish version: 3.3.0 (built from source)
OS version: Linux Mint 20.2 Cinnamon

Quote from docs:

Local variables are specific to the current fish session, and associated with a specific block of commands, and automatically erased when a specific block goes out of scope. A block of commands is a series of commands that begins with one of the commands for, while , if, function, begin or switch, and ends with the command end.

So why set -l works in the following code:

set -l var sample
echo $var # sample

?

What about to add note about it into docs or fix this behavior? I know that it's better to use -g in this case. ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsAn issue/PR that touches or should touch the docs

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions