fish-shell/doc_src
Johannes Altmanninger 1bf2b43d30 Allow { } for command grouping, like begin / end
For compound commands we already have begin/end but

> it is long, which it is not convenient for the command line
> it is different than {} which shell users have been using for >50 years

The difference from {} can break muscle memory and add extra steps
when I'm trying to write simple commands that work in any shell.

Fix that by embracing the traditional style too.

---

Since { and } have always been special syntax in fish, we can also
allow

	{ }
	{ echo }

which I find intuitive even without having used a shell that supports
this (like zsh. The downside is that this doesn't work in some other
shells.  The upside is in aesthetics and convenience (this is for
interactive use). Not completely sure about this.

---

This implementation adds a hack to the tokenizer: '{' is usually a
brace expansion. Make it compound command when in command position
(not something the tokenizer would normally know). We need to disable
this when parsing a freestanding argument lists (in "complete somecmd
-a "{true,false}").  It's not really clear what "read -t" should do.
For now, keep the existing behavior (don't parse compound statements).

Add another hack to increase backwards compatibility: parse something
like "{ foo }" as brace statement only if it has a space after
the opening brace.  This style is less likely to be used for brace
expansion. Perhaps we can change this in future (I'll make a PR).

Use separate terminal token types for braces; we could make the
left brace an ordinary string token but since string tokens undergo
unescaping during expansion etc., every such place would need to know
whether it's dealing with a command or an argument.  Certainly possible
but it seems simpler (especially for tab-completions) to strip braces
in the parser.  We could change this.

---

In future we could allow the following alternative syntax (which is
invalid today).

	if true {
	}
	if true; {
	}

Closes #10895
Closes #10898
2025-01-15 11:18:46 +01:00
..
cmds Allow { } for command grouping, like begin / end 2025-01-15 11:18:46 +01:00
python_docs_theme docs: Distinguish documents in sidebar 2024-12-28 08:42:46 +01:00
commands.rst docs: add short documentation for export 2024-11-06 23:47:31 +08:00
completions.rst docs: Some rewording on completions 2024-05-10 17:40:18 +02:00
conf.py update copyright years to be unbounded 2025-01-08 20:38:43 +08:00
contributing.rst Improve CONTRIBUTING and add it to the docs 2023-06-01 18:09:02 +02:00
design.rst docs: Fix typos 2022-09-17 21:31:06 +08:00
faq.rst docs/faq: Fix some broken keys 2024-11-21 18:28:43 +01:00
fish_for_bash_users.rst fish_for_bash_users: Put explanation on subshells first 2024-05-15 22:44:07 +02:00
fish_indent_lexer.py docs: restore default highlighting keywords and options in HTML 2022-01-16 14:07:19 +01:00
fish_synopsis.py Allow { } for command grouping, like begin / end 2025-01-15 11:18:46 +01:00
index.rst docs: Some slight rewordings 2023-08-23 23:08:56 +02:00
interactive.rst docs/interactive: update key bindings added for 4.0 2025-01-05 22:27:00 +08:00
language.rst Fix typos in docs (#11015) 2025-01-06 19:40:30 -06:00
license.rst update copyright years to be unbounded 2025-01-08 20:38:43 +08:00
prompt.rst docs/prompt: Add funcsave/funced 2024-09-15 09:39:13 +02:00
relnotes.rst docs: call the CHANGELOG "release notes" 2021-02-25 22:46:24 +08:00
tutorial.rst docs: Fix two links 2024-06-22 14:58:07 +02:00