question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Tab completion of Windows commands is not aligned with cross-platform "best practice"

See original GitHub issue

Summary of the new feature / enhancement

According to an article on powershell.org:

On Windows, executable files have the .exe extension. On Linux/MacOS, an executable has file system permissions that mark a file as executable. If you’re searching for or running a command that could exist on all operating systems, omit the extension from the name. On Windows, PowerShell will implicitly add the .exe extension for you (it actually uses the extensions in the PATHEXT environment variable to look for commands).

The issue is that PS7 tab-completion does not follow this guideline for Windows executables. For example, typing dot[Tab] results in dotnet.exe, not dotnet.

Proposed technical implementation details (optional)

Tab-completion for executables should follow the format basename, not basename.ext. Either that or the extension appears, but in dark-grey.

An alternative would be to tab-complete to the basename, and a second tab would add the extension. So robo[Tab] gives Robocopy, and robo[Tab][Tab] gives Robocopy.exe.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:15 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
mklement0commented, Jan 17, 2023

Agreed, @jhoneill, but my point was that even if you carefully manage the scope of your strict-mode settings to avoid affecting other code - which you should always do - even your own code is at risk of breaking if you ship something with Set-StrictMode -Latest in effect, given that if a future PowerShell version introduces a new strict-mode version with even more stringent checks, your code may then fail those checks.

1reaction
sdwheelercommented, Jun 14, 2023

The WG reviewed this issue. The tab completion is just resolving the filename. On the Windows platform, that includes the extension. Changing that behavior can be risky. If you are scripting for cross-platform scenarios it is your responsibility to handle using the proper name of the executable on the target platforms. Tab expansion was never meant to be cross-platform aware.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Tab completion for System.CommandLine
How to enable and customize tab completion for apps built on the System. ... Command Prompt) there is no pluggable tab completion mechanism, ......
Read more >
PowerShell 7 Cross-Platform Best Practices
When PowerShell was first released, the goal was to bring powerful scripting tools to Windows, which typically had GUI-based administration ...
Read more >
What's the strategy for handling CRLF (carriage return, line ...
To sum-up for me the best practice is: Make sure that every non-binary file is committed with LF on git repo (default behaviour)....
Read more >
Command line r21
Dcdiag is a Microsoft Windows command line utility that can analyze the state of domain controllers in a forest or enterprise. Command Mode....
Read more >
Python GUI Programming With Tkinter
In this tutorial, you'll learn the basics of GUI programming with Tkinter, the de facto Python GUI framework. Master GUI programming concepts such...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found