cygwin: improve handling of .exe file extension

- Prefer the command name without `.exe` since the extension is optional
when launching application on Windows...
- ... but if the user started to type the extension, then use it.
- If there is no description and/or completion for `foo.exe` then
use those for `foo`

Closes #12100
This commit is contained in:
Nahor
2025-11-22 17:53:27 -08:00
committed by Johannes Altmanninger
parent a4b949b0ca
commit 7fc27e9e54
11 changed files with 243 additions and 57 deletions

View File

@@ -103,6 +103,31 @@ When erasing completions, it is possible to either erase all completions for a s
When ``complete`` is called without anything that would define or erase completions (options, arguments, wrapping, ...), it shows matching completions instead. So ``complete`` without any arguments shows all loaded completions, ``complete -c foo`` shows all loaded completions for ``foo``. Since completions are :ref:`autoloaded <syntax-function-autoloading>`, you will have to trigger them first.
.. _completions-cygwin:
Cygwin / MSYS2 / Windows
------------------------
On Windows, binary executables have a ``.exe`` extension, but this extension is not required when calling an application (and if the name is not ambiguous, i.e. there isn't also a script called ``myprog`` in the same directory as ``myprog.exe``).
To unify completions between Windows and other OSes, on Cygwin/MSYS2/Windows, *COMMAND* does not require the ``.exe`` extension.
Completions for ``myprog`` will also be used for ``myprog.exe`` if there are no ambiguities, i.e. if there are no completions for ``myprog.exe`` specifically.
However, completions for ``myprog.exe`` will only be used when also using the ``.exe`` extension on the command line.
In other words:
::
complete -c myprog.exe ... #1
will only work for ``myprog.exe``
::
complete -c myprog ... #2
can work for both ``myprog`` and ``myprog.exe``. But if both completions exist, #2 will only be used for ``myprog`` while ``myprog.exe`` will use #1.
Examples
--------