Open REmerald opened 5 months ago
Thank you for the detailed report, which was sufficient to reproduce the problem.
I added an adjustment in commit https://github.com/akinomyoga/ble.sh/commit/0cf0383a912c723606ea4f88ca2d17322f1e10fe. I haven't tested with the actual Django command, so could you update ble.sh by running ble-update
and see if the problem is fixed?
Actually, the original behavior was a part of the intentional behavior change by ble.sh to improve the completion, but I haven't assumed cases where the completion that applies to the relative-path commands (such as ./manage.py
) is registered with the basename of the command (as complete -F _django_completion manage.py
as in the provided django-admin.py.txt
). I decided to adjust the behavior of ble.sh's programmable completion.
For more context, the programmable completion of plain Bash doesn't support the cases where the command names are quoted, such as './manage.py' m[TAB]
or "./manage.py" m[TAB]
or \./manage.py m[TAB]
. The last one is partially covered by the bash-completion project, but it still fails with the Django completion. To cover such a situation, ble.sh
tried to virtually reconstruct the command line as manage.py m[TAB]
(where the command name is replaced by the name registered to complete
) and then called the completion functions.
For the provided case of Django, even though the actual command seems to be called by ./manage.py
, the registered name is manage.py
. This made ble.sh
reconstruct the command line as manage.py m[TAB]
but not ./manage.py m[TAB]
. Then, the completion for Django seems to try to execute the command name in the command line, which resulted in the execution attempt of non-existent manage.py
. I adjusted ble.sh to reconstruct the command line using the value of the specified command name while removing the quotes if possible.
@akinomyoga Updated, works now (the behavior now is the same as pure bash). Thanks.
Works with both ./manage.py m[TAB]
, Documents/.../manage.py m[TAB]
and /home/remorin/Documents/.../manage.py m[TAB]
. (Haven't actually tested the last one before the fix. Maybe it would have worked?)
Let me know if there're more situations like these 3 I should test.
(Haven't actually tested the last one before the fix. Maybe it would have worked?)
It shouldn't have worked before either.
Let me know if there're more situations like these 3 I should test.
I think these are sufficient. Thank you!
@akinomyoga the issue is still present if I try to execute the file indirectly (as an argument to the interpreter):
[remorin@chuwawa:0 antih]$ ah_env/bin/python manage.py mbash: manage.py: command not found
mibash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
migbash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
ah_env/bin/python manage.py mig
[remorin@chuwawa:0 antih]$ python manage.py mbash: manage.py: command not found
mibash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
bash: manage.py: command not found
python manage.py mi
[remorin@chuwawa:0 antih]$
Sorry for the delay. Now some issues are stacking, so it will still take some time. Hopefully, I can look at this next week.
The issue is caused by blesh trying to complete arguments to file
manage.py
created bydjango-admin startproject ah_project .
:Same without autocompletion on TAB:
Without blesh, completion works as expected:
./manage.py mig
->./manage.py migrate
,./manage.py m
->Removing only
/usr/share/bash-completion/completions/manage.py
"fixes" in on both blesh and pure bash, completion just reverts to file completion. FYI, this is just a symlink to/usr/share/bash-completion/completions/django-admin.py
Here's the files (renamed because of github): manage.py.txt django-admin.py.txt