Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

begin-end command grouping isn't discoverable/documented prominently enough #6415

Closed
ulidtko opened this issue Dec 11, 2019 · 1 comment
Closed
Labels
docs An issue/PR that touches or should touch the docs enhancement
Milestone

Comments

@ulidtko
Copy link

ulidtko commented Dec 11, 2019

Hi!

One thing with fish that I've stumbled over multiple times across years of usage, are situations of this kind: when I have a pipe, and need to inject another command into just one end of the pipe. Nigh realistic example:

🐟 printf 'GET / HTTP/1.1\nHost: example.net\n\n' | openssl s_client -connect example.net:443 -crlf -servername example.net -quiet

With this example, I need to test the server request timeout.
So my bash muscle does this before I even think:

🐟 { sleep 0.1; printf 'GET / HTTP/1.1\nHost: example.net\n\n' } | openssl s_client -connect example.net:443 -crlf -servername example.net -quiet

... which of course fails with fish: Illegal command name “{”.


It's not my aim to discuss syntax here; I was able to somehow discover the proper way to say it in fish:

🐟 begin echo ccc; echo zzz; echo aaa; end | sort
aaa
ccc
zzz

🐟 begin sleep 0.1; printf 'GET / HTTP/1.1\nHost: example.net\n\n'; end | openssl s_client -connect example.net:443 -crlf -servername example.net -quiet

What I want to raise issue with — it's too easy to forget and too hard to rediscover. The quick syntax guide, upon skimming, doesn't give answers. begin; end is demonstrated just once, in an example for something different; not easy to spot when you "don't know what you're looking for".

Better yet. Can fish suggest begin; end in the error message for Illegal command name “{”?
Just like it does in Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.

I think I can roll an easy patch for this — if it sounds good, and the community approves. RFC!

@krobelus
Copy link
Member

Better yet. Can fish suggest begin; end in the error message for Illegal command name “{”?
Just like it does in Unsupported use of '&&'. In fish, please use 'COMMAND; and COMMAND'.

A helpful error message would definitely be a great change. It might not
be straightforward because of brace expansion but maybe there's a
simple way to do it.

Btw fish 3 does support && and || :)

Supporting brace grouping natively could be a possibility for the future.
Or ship abbreviations like abbr { begin, but that doesn't work as of now.

@faho faho added enhancement docs An issue/PR that touches or should touch the docs labels Dec 11, 2019
@faho faho added this to the fish-future milestone Dec 11, 2019
@krobelus krobelus modified the milestones: fish-future, fish 3.3.0 Jun 23, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docs An issue/PR that touches or should touch the docs enhancement
Projects
None yet
Development

No branches or pull requests

3 participants