You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can only bind key sequences to functions listed in bind --function-names - Cygwin, fish 2.2.0 #2284
I recently opened (and closed) #2260 because the up-arrow key would only print a square with an x through it. I initially thought it was because of terminfo stuff, but eventually determined it was the 'up-or-search' function. I was able to bind up-arrow to history-search-backward, which was good enough at the time.
I have since installed fish on a FreeBSD box I have and it behaves much better than it does on Cygwin. So I now know up-or-search should not behave that way.
I've noticed some other peculiarities now. \cc also prints a box with an x through it. \cl does too. And I think I can see what the common thread is in all of this. Any binding that invokes the commandline function fails -- this includes up-or-search which is the first problem function I noticed.
I can run commandline on the command line and it does what it should. It's just broken when invoked from a function called by a key binding. It does work when invoked directly by a function (e.g. I can run up-or-search on the command line and while not particularly useful it does what it should and doesn't print a box with an x through it).
I agree that it doesn't do much when run directly, my only point was that it does complete succesfully and it does do something other than printing � (on my terminal that is a box with an x through it).
I realized after I opened this issue that it goes far beyond commandline. Even very simple functions or commands don't work when invoked from a key binding. For example, the following binding also causes the square to be printed when I hit ctrl-d:
bind \cd exit
From my testing it looks like the only bindings that DON'T cause the square to be printed are bindings that invoke functions that are listed by bind --function-names. Everything else prints a square.
There's still enough functionality in those functions to make fish reasonably useful. I can bind up and down to history-search-backward and history-search-forward, I can bind ctrl-c to kill-whole-line, etc. But there is a lot of functionality that is being left on the table.
I did have to make a couple of changes to get it to work reasonably well on Cygwin:
I had to remove -rdynamic from LDFLAGS_FISH options
I changed the default notifier strategy to strategy_shmem_polling
I tried using the pre-2.2.0 versions, both the one with a package in Cygwin and one I built from the 2.1.2 source myself. It's a non-starter because it crashes too often. This bind issue is a nuisance to be sure but it isn't a showstopper.
changed the title [-]Can't use commandline function in any binding - Cygwin, fish 2.2.0[/-][+]Can only bind key sequences to functions listed in bind --function-names - Cygwin, fish 2.2.0[/+]on Aug 15, 2015
By the way -- I don't know if it's bad form to put this in here but fish is great. I really like the approach you have taken to come up with one set of rules that apply everywhere. This is the first shell I've used that makes sense to me.
This is very surprising behavior. I think the place to start looking is in input_mapping_execute. It would be helpful to know the following (e.g. printf debugging). In this function, "functions" refers to readline functions (bind --function-names) and "commands" refers to fish script commands.
Does input_mapping_execute ever run with allow_commands set to true?
If so, does has_commands get set to true?
If so, does principal_parser().eval() execute?
My speculative guess is that we're being bitten by differences in the width of wchar_t on Windows *nix.
Thanks for your guidance. I added some fprintf statements to output the information you suggested. In every case, allow_commands is true, has_commands is false.
OK, I added a lot more debugging statements and I have determined that input_function_get_code is definitely returning -1, but input_mapping_execute is definitely interpreting that to mean it is a function. So I changed the code to this, on the assumption that the data type conversion is what was making it fail, and it now works!
wchar_t test_against = -1;
for (wcstring_list_t::const_iterator it = m.commands.begin(), end = m.commands.end(); it != end; it++)
{
fprintf(stderr, "testing command %S\n", it->c_str());
if (input_function_get_code(*it) != test_against) {
fprintf(stderr, "calling it a function\n");
has_functions = true;
} else {
has_commands = true;
}
}
Activity
macdanny commentedon Aug 12, 2015
Actually it fails on any function not listed in the output of "bind --function-names"
ridiculousfish commentedon Aug 12, 2015
I don't think
commandlinedoes much when run directly. Here's a simple test:When you type that
qat the end, it should causefoobarto be printed again. Does that work?macdanny commentedon Aug 15, 2015
I agree that it doesn't do much when run directly, my only point was that it does complete succesfully and it does do something other than printing � (on my terminal that is a box with an x through it).
I realized after I opened this issue that it goes far beyond commandline. Even very simple functions or commands don't work when invoked from a key binding. For example, the following binding also causes the square to be printed when I hit ctrl-d:
bind \cd exit
From my testing it looks like the only bindings that DON'T cause the square to be printed are bindings that invoke functions that are listed by bind --function-names. Everything else prints a square.
There's still enough functionality in those functions to make fish reasonably useful. I can bind up and down to history-search-backward and history-search-forward, I can bind ctrl-c to kill-whole-line, etc. But there is a lot of functionality that is being left on the table.
I did have to make a couple of changes to get it to work reasonably well on Cygwin:
I tried using the pre-2.2.0 versions, both the one with a package in Cygwin and one I built from the 2.1.2 source myself. It's a non-starter because it crashes too often. This bind issue is a nuisance to be sure but it isn't a showstopper.
[-]Can't use commandline function in any binding - Cygwin, fish 2.2.0[/-][+]Can only bind key sequences to functions listed in bind --function-names - Cygwin, fish 2.2.0[/+]macdanny commentedon Aug 15, 2015
By the way -- I don't know if it's bad form to put this in here but fish is great. I really like the approach you have taken to come up with one set of rules that apply everywhere. This is the first shell I've used that makes sense to me.
ridiculousfish commentedon Aug 15, 2015
Thanks for the praise :)
This is very surprising behavior. I think the place to start looking is in
input_mapping_execute. It would be helpful to know the following (e.g. printf debugging). In this function, "functions" refers to readline functions (bind --function-names) and "commands" refers to fish script commands.input_mapping_executeever run withallow_commandsset to true?has_commandsget set to true?principal_parser().eval()execute?My speculative guess is that we're being bitten by differences in the width of wchar_t on Windows *nix.
macdanny commentedon Aug 16, 2015
Thanks for your guidance. I added some fprintf statements to output the information you suggested. In every case, allow_commands is true, has_commands is false.
macdanny commentedon Aug 16, 2015
OK, I added a lot more debugging statements and I have determined that input_function_get_code is definitely returning -1, but input_mapping_execute is definitely interpreting that to mean it is a function. So I changed the code to this, on the assumption that the data type conversion is what was making it fail, and it now works!
ridiculousfish commentedon Aug 16, 2015
Nice! We should define a wchar_t constant for not-found.
Define a constant for function-not-found in input.cpp
ridiculousfish commentedon Aug 17, 2015
Can you please try e2f16ec (on master or cherry-picked)?
macdanny commentedon Aug 17, 2015
It works :)
Thank you, I really appreciate you looking into this.
I see the issue with "-rdynamic" was also fixed at some point -- much obliged.
ridiculousfish commentedon Aug 17, 2015
Coolio
Define a constant for function-not-found in input.cpp