fish-shell / fish-shell/fish-shell

Literal brace expansion is buggy

Open
#9,351 7 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
34.2k
Forks
2.4k
Avg merge
2d 8h
Merged PRs (30d)
13

Description

A while ago, a patch was added when it was observed that the majority of cases involving `{}` were accidental and intended the literal braces to be printed/evaluated rather than invoking cartesian expansion. This was then also expanded to consider `{x}` where `x` is anything that doesn't contain an unescaped `,` to _also_ be taken as a literal expression and not enter a special parsing mode.

I've recently discovered that this isn't done quite right and that whitespace within `{}` braces is emitted literally as if escaped rather than coalesced:

```
> printf "'%s'\n" { }
'{ }'
```

I don't believe this is intentional, and even if it were, I believe it shouldn't be parsed as such. Treating `{` and `}` as literal tokens at the parser level is fine, but we don't have any concepts of literal whitespace except when individually prefixed with `\` or when in a quoted context. It also goes against how brace expansion handles whitespace in general:

```
> printf "'%s'\n" { hello , world }
'hello'
'world'
```

It's ok to treat `{one}` as a single, literal token but IMHO `{ one }` should be treated as three separate tokens.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.