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
source
reads from stdin (was: fish hangs up after command substitution failed during initialization)
#2633
Comments
Well, the issue here is that I'm not sure how or if this should be fixed. |
Out of curiosity - why a function? Why not a variable? |
This seems like it should be a bug. I know the documentation says that if no filename is specified stdin will be used. But wouldn't it be better to require the user be explicit about their desire to source stdin by requiring the use of the "-" pseudo-filename? This would also protect against this very scenario. Even if a var was being used instead of a function mistyping the var name will result in the entire argument being removed, without so much as an error being reported, leaving source reading unexpectedly from stdin. The other question is whether source should be interruptible. I vote yes especially if we continue to allow a bare |
Quite possibly source should only use stdin if it's not a tty - since I can't see a use case for that. In other, more code-y words: > source
source: You can just enter the commands you wish to source directly since you are already typing on this terminal
> echo "echo banana" | source
banana
> source (_fish_NONEXISTENT_FUNCTION)
fish: Unknown command '_fish_NONEXISTENT_FUNCTION
source: You can just enter the commands you wish to source directly since you are already typing on this terminal Or maybe tie it to interactivity?
Currently |
Tying the ability to use a bare |
Good point. This would also occur for fish functions, meaning the interactivity check wouldn't help.
So you'd disallow bare One thing that would improve this is #1246 - by failing in this particular case before executing So, there's three things to be done here:
|
Yes. For all the reasons I already mentioned plus two more: It doesn't even make an improvement to the interactive user experience, and it's redundant. I agree with your three action items. Whether or not a --stdin flag should be added in addition to supporting "-" is something I'm agnostic about. It's redundant but it does improve readability. I dislike breaking backward compatibility but in this instance I'm betting (well, hoping) there are extremely few uses of the feature. If people believe this will affect more than a handful of users we could do it in two steps. Step 1: disallow a bare source if stdin is not a tty and update the documentation to make it clear that x months later a bare source won't be legal. Step 2: When that milestone is reached disable the feature completely. |
I found that If I wrapped a pathname in quotes, like:
the tilde wouldn't be expanded. That's why I would have to make use of the echo command for tilde expansion.
But a few hours ago after doing some searching on Google I knew that the proper pattern is without quotes:
It is more succinct than defining a function. Great! |
source
reads from stdin (was: fish hangs up after command substitution failed during initialization)
This can also happen if executing I think the discussion is missing the fact that there's an actual underlying bug wherein source can't read from stdin when called during startup. As @imcaizheng says, ctrl+d doesn't end source, either. |
I have now decided to fix this by requiring an explicit "-" to read from the terminal. The solution I went with has |
For things like source $undefined or source (nooutput) it was quite annoying that it read from tty. Instead we now require a "-" as the filename to read from the tty. This does not apply to reading from stdin if it's redirected, so something | source still works. Fixes fish-shell#2633.
I tried to put
source (_fish_config_dir)alias.fish
in my local configuration file.After that fish complains an error and freezes every time I open a new terminal. Both Ctrl-D and Ctrl-C don't work.
I had copied the complained text as showed below:
I do have a function named __fish_config_dir in the functions directory and just made a typo. Fortunately I fixed the typo with a GUI text editor and everything goes well again.
Seems that it is a bug from the source command because fish would not be hanging up but complains error after I put
echo (command_not_exists)
in the local configuration file.fish version: fish, version 2.2.0-473-g8a6f26f-dirty
The text was updated successfully, but these errors were encountered: