Repository navigation
Builtin indent and key reader - #10876
Conversation
0c1885c to
0305f47
Compare
|
|
That's right, and this doesn't change it. We could remove one or both of them in future if we go through with this. I doubt fish_key_reader sees much use (it's too tied to fish's bind notation for it).
That's the big thing. We could have a fish.xz, and you would decompress and put it wherever you want. Installing fish on a machine would be (I think we may still want a tarball because of permissions, I'm unsure) Uninstallation is Plus we could guarantee that E.g. see funced, where we call fish-shell/share/functions/funced.fish Line 55 in 2d1ad1c That can be entirely removed with this because it's just always available. |
|
This is a good idea; I like this direction. |
| let long_opts: &[WOption] = &[ | ||
| wopt(L!("debug"), ArgType::RequiredArgument, 'd'), | ||
| wopt(L!("debug-output"), ArgType::RequiredArgument, 'o'), | ||
| wopt(L!("debug-stack-frames"), ArgType::RequiredArgument, 'D'), |
There was a problem hiding this comment.
I am inclined to remove these debug options - they've never been very useful and are awkward from inside fish. The third is also unused and has been for years now.
I would also move "--version" to the throwing_main because it is weird to have a builtin write its version?
There was a problem hiding this comment.
Note: fish_indent --version is called from doc_src/conf.py to determine the version for the docs.
This should probably be passed in from the build script via an environment variable, like it already is in #10367.
| '\x03' => output_type = OutputType::PygmentsCsv, | ||
| 'c' => output_type = OutputType::Check, | ||
| 'd' => { | ||
| activate_flog_categories_by_pattern(w.woptarg.unwrap()); |
There was a problem hiding this comment.
This currently allows activating debug options globally by running fish_indent.
I'm not sure we currently have anything else to do that?
There was a problem hiding this comment.
I've removed these - we would have to do some work to make them not affect the running fish session, and they don't really apply to the fish_indent itself.
If you want to debug how some script parses, you can use fish --no-execute --debug ....
| wopt(L!("write"), ArgType::NoArgument, 'w'), | ||
| wopt(L!("html"), ArgType::NoArgument, '\x01'), | ||
| wopt(L!("ansi"), ArgType::NoArgument, '\x02'), | ||
| wopt(L!("pygments"), ArgType::NoArgument, '\x03'), |
There was a problem hiding this comment.
This is used by our docs - we highlight the code samples by shelling out to fish_indent.
That would have to be adjusted to call fish -c 'fish_indent $argv' args if we decide to drop the second binary.
There was a problem hiding this comment.
Note: Making it fish -c would have to change the build order, but then it's extremely weird to have fish_indent, docs, fish in that order to begin with, and I'm not sure it helps anyone.
(we can't currently build the html docs without the corresponding fish_indent for lexing, which is a bit of a downside for #10367)
|
Also: This gives us the opportunity to rename We could call it Not saying we have to, but I wouldn't be opposed. |
|
Sounds good. Renaming would be great (also underscores are odd, I'd rather use "-" or no separator).
|
| // We need to set the shell-modes for ICRNL, | ||
| // in fish-proper this is done once a command is run. | ||
| unsafe { libc::tcsetattr(0, TCSANOW, &*shell_modes()) }; | ||
| terminal_protocol_hacks(); |
There was a problem hiding this comment.
these 3 statements should not be necessary when running as builtin
There was a problem hiding this comment.
hmm except for TCSANOW which we need to keep it seems. Should try to clean this up eventually
There was a problem hiding this comment.
The important bit here is the shell_modes, which we unset while running a builtin, apparently?
Tbh I'd want to leave this for now, it seems harmless either way.
If we did rename, I would want it to be more substantial change than Like I said, my favorite is fishfmt. |
bd71cfc to
cb530e3
Compare
|
An alternative is to replace This would make it easier to call from the outside if you don't have symlinks (e.g. if you installed via However, there are some issues with that:
The issue with renaming is that we would have to keep the old name around longer in some way, even from the outside. So we'd leave a Overall, thinking more about it I don't think it's worth it. Those are the questions I would like to have answers to before merging this, because that's the easiest time to do so. |
|
Disk is cheap and compression is good (there's essentially no difference in size between a .xz with one or two copies of the same binary, if they're stripped), I'd not bother with a symlink for now. Maybe make a note in the README for distributors who want to symlink instead. I also don't think there's much to be gained from a rename. |
261531a to
1560c80
Compare
This brings us closer to making fish available as a single file.
1560c80 to
a9926fb
Compare
|
I've decided to merge this now so we can get some experience in. There are improvements to be made, but it's already useful. |
|
|
Description
This makes it so fish_key_reader and fish_indent are available as builtins. That makes it easier to distribute fish as a single file (especially when paired with #10367).
However, to allow calling them from the outside, the main
fishbinary now checks its argv[0] - if that uses a filename "fish_indent" or "fish_key_reader", it will immediately become the respective program and exit. This is like how busybox can be ls or rm or a shell.TODOs:
This is pretty rough and WIP. A quick attempt to see how well it works.
And the big picture:
fish -c fish_indentinstead? Deprecate the links?fish_key_readera big enough thing that it deserves a link? Or is it only ever called inside of fish?