fish-shell/doc_src/cmds
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
..
_.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
abbr.rst Fix typos in docs (#11015) 2025-01-06 19:40:30 -06:00
alias.rst Minor doc fixes 2024-09-18 22:11:14 +02:00
and.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
argparse.rst docs/argparse: Explain dashes in flag names 2024-09-15 09:39:09 +02:00
begin.rst Allow { } for command grouping, like begin / end 2025-01-15 11:18:46 +01:00
bg.rst docs: Improve bg docs 2023-06-05 18:26:13 +02:00
bind.rst Make new ctrl-c behavior "clear-commandline" 2025-01-14 20:01:56 +01:00
block.rst Clarify block command documentation 2024-04-23 19:36:11 +02:00
break.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
breakpoint.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
builtin.rst docs: Document type/builtin exit status 2022-09-30 18:50:14 +02:00
case.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
cd.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
cdh.rst docs: use canonical key names in :kbd: tags 2024-04-20 15:36:29 +02:00
command.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
commandline.rst Fix typos in docs (#11015) 2025-01-06 19:40:30 -06:00
complete.rst docs/complete: Explain -r a bit better 2024-09-15 09:44:09 +02:00
contains.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
continue.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
count.rst docs synopsis: make all placeholder arguments uppercase 2022-01-19 22:56:41 +08:00
dirh.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
dirs.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
disown.rst docs: Clarify that disowned jobs won't fire on-process/job-exit 2024-03-19 16:39:37 +01:00
echo.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
else.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
emit.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
end.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
eval.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
exec.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
exit.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
export.rst docs/export: Add a bit on PATH=$PATH:... 2024-11-06 18:50:41 +01:00
false.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fg.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fish_add_path.rst fish_add_path: Automatically enable verbose mode for interactive use 2024-06-06 16:47:39 +02:00
fish_breakpoint_prompt.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fish_clipboard_copy.rst docs: use canonical key names in :kbd: tags 2024-04-20 15:36:29 +02:00
fish_clipboard_paste.rst docs: use canonical key names in :kbd: tags 2024-04-20 15:36:29 +02:00
fish_command_not_found.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_config.rst docs: Turn off highlighting correctly in fish_config 2023-06-16 16:17:58 +02:00
fish_default_key_bindings.rst Correct fish_default_key_bindings docs 2024-06-15 12:18:37 -07:00
fish_delta.rst Add a fish_delta helper function 2022-10-19 20:06:35 +02:00
fish_git_prompt.rst git prompt: Interpret values of "1", "yes" or "true" as true for bools instead of relying on defined-or-not (#9274) 2022-10-21 20:22:20 +02:00
fish_greeting.rst docs: fix double space in example fish_greeting 2024-01-06 15:26:20 +01:00
fish_hg_prompt.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fish_indent.rst Teach fish_indent to only indent and unindent 2024-04-15 08:32:31 +02:00
fish_is_root_user.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_key_reader.rst Add back docs for fish_key_reader --verbose 2024-08-11 14:57:04 +02:00
fish_mode_prompt.rst docs: standardise name for vi mode 2023-12-17 17:40:45 +08:00
fish_opt.rst Fix small typos 2023-11-18 18:27:25 -08:00
fish_prompt.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_right_prompt.rst We no longer have two doc systems, move sphinx_doc_src back to doc_src 2020-02-19 17:00:35 -08:00
fish_should_add_to_history.rst docs: Add fish_should_add_to_history to commands list 2024-03-09 12:09:00 +01:00
fish_status_to_signal.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_svn_prompt.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fish_title.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_update_completions.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
fish_vcs_prompt.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
fish_vi_key_bindings.rst docs: standardise name for vi mode 2023-12-17 17:40:45 +08:00
fish.rst Allow installable builds to be installed into a specific path (#10923) 2024-12-22 18:16:07 +01:00
for.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
funced.rst docs: Point to functions/type from funced/funcsave 2024-08-13 17:44:23 +02:00
funcsave.rst docs: Point to functions/type from funced/funcsave 2024-08-13 17:44:23 +02:00
function.rst Explain function --argument-names in more detail. (#10524) 2024-06-19 22:51:47 -05:00
functions.rst functions --copy: store file and lineno (#9542) 2023-02-13 09:59:28 -06:00
help.rst docs: More about envvars 2023-01-09 20:33:37 +01:00
history.rst add history append subcommand 2024-04-15 08:31:16 +02:00
if.rst docs/if: Link to other builtins 2023-02-28 20:49:11 +01:00
isatty.rst Fix formatting for isatty 2022-10-19 20:10:26 +02:00
jobs.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
math.rst feat(math): add round options (#9117) 2024-06-23 17:45:52 -05:00
nextd.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
not.rst Document the ! (not) and . (source) aliases more 2024-04-20 13:34:08 +02:00
open.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
or.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
path.rst fix documentation for path normalize 2024-10-27 08:32:05 +00:00
popd.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
prevd.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
printf.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
prompt_hostname.rst docs synopsis: add HTML highlighing and automate manpage markup 2022-01-19 22:56:41 +08:00
prompt_login.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
prompt_pwd.rst docs/prompt_pwd: Fix envvar linking 2022-12-30 14:31:32 +01:00
psub.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
pushd.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
pwd.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
random.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
read.rst docs: Fix some formatting 2024-05-27 23:21:06 +02:00
realpath.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
return.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
set_color.rst docs: Fix markdown links 2023-11-22 18:42:34 +01:00
set.rst docs: Update synopsis for 'set' 2024-09-14 10:29:44 +02:00
source.rst Document the ! (not) and . (source) aliases more 2024-04-20 13:34:08 +02:00
status.rst Add status buildinfo (#10896) 2024-12-29 13:37:28 +01:00
string-collect.rst Fix more lost string documentation 2022-05-14 10:05:02 +02:00
string-escape.rst Improve documentation for string escape 2024-12-29 13:48:34 -08:00
string-join.rst New -n flag for string join. (#8774) 2022-03-13 11:47:33 +01:00
string-join0.rst We no longer have two doc systems, move sphinx_doc_src back to doc_src 2020-02-19 17:00:35 -08:00
string-length.rst string docs: format options and arguments in line with other pages 2022-03-12 22:22:02 +08:00
string-lower.rst string docs: format options and arguments in line with other pages 2022-03-12 22:22:02 +08:00
string-match.rst Fix short/long delimiter in string {match,replace} 2024-07-06 16:18:14 +02:00
string-pad.rst docs/string: Separate "pad" and "shorten" 2023-04-20 22:17:08 +02:00
string-repeat.rst Fix typos in docs (#11015) 2025-01-06 19:40:30 -06:00
string-replace.rst string-replace.rst: fix trailing whitespace 2024-07-23 11:47:58 +02:00
string-shorten.rst Fix typos in docs (#11015) 2025-01-06 19:40:30 -06:00
string-split.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
string-split0.rst We no longer have two doc systems, move sphinx_doc_src back to doc_src 2020-02-19 17:00:35 -08:00
string-sub.rst Fix more lost string documentation 2022-05-14 10:05:02 +02:00
string-trim.rst docs/string-trim: Double down on the set of chars vs string thing 2024-11-25 17:53:14 +01:00
string-unescape.rst We no longer have two doc systems, move sphinx_doc_src back to doc_src 2020-02-19 17:00:35 -08:00
string-upper.rst string docs: format options and arguments in line with other pages 2022-03-12 22:22:02 +08:00
string.rst Add documentation and release notes for #10282 2024-02-11 12:43:13 +01:00
suspend.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
switch.rst docs: More about envvars 2023-01-09 20:33:37 +01:00
test.rst Deprecate builtin test's one- and zero-argument modes (#10365) 2024-04-21 14:25:54 +02:00
time.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
trap.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
true.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00
type.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
ulimit.rst docs: Fix typos 2022-09-17 21:31:06 +08:00
umask.rst Reference more non-fish shell builtins that have relevant differences 2024-04-20 13:34:08 +02:00
vared.rst docs: omnibus cleanup 2022-03-12 00:21:13 +08:00
wait.rst Minor doc fixes 2024-09-18 22:11:14 +02:00
while.rst docs: Use :doc: role when linking to commands 2022-09-24 10:56:43 +02:00