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

stdout is not a terminal in fish_command_not_found? #9806

Closed
emilazy opened this issue May 23, 2023 · 3 comments
Closed

stdout is not a terminal in fish_command_not_found? #9806

emilazy opened this issue May 23, 2023 · 3 comments
Labels

Comments

@emilazy
Copy link

emilazy commented May 23, 2023

This came up while porting a command-not-found script to fish and I'm genuinely not sure what's going on here. 0 and 2 (stdin and stderr) behave normally. Can anyone explain this behaviour to me or is it a strange bug? Something to do with the way the output of fish_command_not_found is handled?

emily@yuyuko ~> sh -c 'env HOME=$(mktemp -d) fish'
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
emily@yuyuko /U/emily> fish --version
fish, version 3.6.1
emily@yuyuko /U/emily> echo $version
3.6.1
emily@yuyuko /U/emily> function emily_test; if ! test -t 1; echo oops; end; end
emily@yuyuko /U/emily> emily_test
emily@yuyuko /U/emily> function fish_command_not_found; if ! test -t 1; echo oops; end; end
emily@yuyuko /U/emily> this-command-does-not-exist
oops
emily@yuyuko /U/emily [127]> fish_command_not_found
emily@yuyuko /U/emily> 
@faho
Copy link
Member

faho commented May 23, 2023

It is run in a command substitution, stdout is a buffer.

@faho faho added the question label May 23, 2023
@emilazy
Copy link
Author

emilazy commented May 23, 2023

That makes sense, thanks. I was a bit confused because it behaves the same even if you factor out the test into another function and do e.g. >&2 but maybe that's just a normal property of command substitutions. Not really a bug, then.

@emilazy emilazy closed this as completed May 23, 2023
@emilazy
Copy link
Author

emilazy commented May 23, 2023

(Though I wonder how one should handle the case where the command not found handler wants to execute an alternate command instead that wants direct access to the original stdout the not-found command was run with, e.g. to do install-on-demand type things?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants