PowerShell icon indicating copy to clipboard operation
PowerShell copied to clipboard

Feedback provider for legacy usage

Open SteveL-MSFT opened this issue 1 year ago • 10 comments

Summary of the new feature / enhancement

Users switching from cmd or bash may have muscle memory for commonly used commands with parameters. It would be useful to have a FeedbackProvider detect this and inform the user what the correct PowerShell syntax would be and have a predictor so that it can fill in the suggested fix.

Common use cases:

rm -rf dir /s/q

Please add your own to this issue.

Proposed technical implementation details (optional)

No response

SteveL-MSFT avatar Apr 17 '23 20:04 SteveL-MSFT

From cmd, I find myself doing

  • dir /s /b
  • rd /s /q

rainersigwald avatar Apr 17 '23 20:04 rainersigwald

Yes, rd /s /q is the primary reason I'm still using cmd instead of PowerShell

sylveon avatar Apr 17 '23 23:04 sylveon

ipconfig arp netstat tracert ping route

frndlyy avatar Apr 17 '23 23:04 frndlyy

dir /a:h to see hidden files cmd /c dir /a:h works of course, I just get an error first and remember to add that

AdilHindistan avatar Apr 18 '23 00:04 AdilHindistan

nslookup ping -t shutdown /r /t 0 echo wget curl set (to display environment variables, cmd) icacls (huge rabbit hole but would be nice if it had a translation table, from icacls to set-acl)

ehmiiz avatar Apr 18 '23 04:04 ehmiiz

In recent history this has been provided for UNIX by "rosetta stones", eg https://www.lurklurk.org/rosetta.html or https://bhami.com/rosetta.html. This would be easier to manage as an external page rather than a feedback provider.

One might say that the origin of the problem in PowerShell is the concept of mapping aliases of commands with the same name to something that does something different.

rhubarb-geek-nz avatar Apr 18 '23 04:04 rhubarb-geek-nz

Rosetta stones does not solve the frustration of broken muscle memory

sylveon avatar Apr 18 '23 05:04 sylveon

ls -la Always gets me

mtnrbq avatar Apr 18 '23 10:04 mtnrbq

ipconfig arp netstat tracert ping route

These commands all still work in PowerShell. There are equivalent commands for some things, but if you want Test-NetConnection instead of ping it is probably because you want different functionality

nslookup ping -t shutdown /r /t 0 echo wget curl set (to display environment variables, cmd) icacls (huge rabbit hole but would be nice if it had a translation table, from icacls to set-acl)

Mostly the same although there are some things in shutdown.exe that stop-computer / restart-computer doesn't same able to do. Set is an obvious one which is missing. Things like curl vs invoke-webrequest if you know curl and you don't need any other functionality then using what you would use in another shell is fine. . Echo is aliased so the muscle memory works

dir /a:h to see hidden files cmd /c dir /a:h works of course, I just get an error first and remember to add that

It took me ages to learn that dir -force in Powershell returned hidden and system files, but "filter to just hidden" is clunky.

One that gets me is in most languages we can create an object with Var = New Object-type, but in PS, New is the old -Object cmdlet that doesn't have an alias to the verb without the -Object

jhoneill avatar Apr 18 '23 11:04 jhoneill

rm -rf ls -la df -h So unix like tools would be a cool thing

adelarsq avatar Apr 18 '23 12:04 adelarsq

Users switching from cmd or bash may have muscle memory for commonly used commands with parameters.

Is there a need on Linux or macOS? Most of the commands mentioned simply use the underlying implementation so should just work.

PS /home/bythesea> get-command mkdir,ls,pwd,cat,echo,rm,df,curl,wget,ping,traceroute

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     mkdir                                              0.0.0.0    /bin/mkdir
Application     ls                                                 0.0.0.0    /bin/ls
Alias           pwd -> Get-Location                                           
Application     cat                                                0.0.0.0    /bin/cat
Alias           echo -> Write-Output                                          
Application     rm                                                 0.0.0.0    /bin/rm
Application     df                                                 0.0.0.0    /bin/df
Application     curl                                               0.0.0.0    /usr/bin/curl
Application     wget                                               0.0.0.0    /usr/bin/wget
Application     ping                                               0.0.0.0    /bin/ping
Application     traceroute                                         0.0.0.0    /usr/sbin/traceroute

rhubarb-geek-nz avatar Apr 18 '23 18:04 rhubarb-geek-nz

It appears you are trying to recursively and forcibly remove files. In PowerShell, the correct syntax would be:

rm -r -fo

But this isn't really true, because while it is an alias on Windows it uses the native command on Linux and macOS

On Linux

PS> get-command rm

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     rm                                                 0.0.0.0    /bin/rm

On Windows

PS> get-command rm

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Alias           rm -> Remove-Item

So it would be more correct to say

It appears you are trying to recursively and forcibly remove files.  In PowerShell, the correct syntax would be:

   Remove-Item -Recurse -Force

If you want users to write portable scripts.

rhubarb-geek-nz avatar Apr 19 '23 05:04 rhubarb-geek-nz

you like?

TheOriginalPiff avatar Apr 19 '23 05:04 TheOriginalPiff

Set is an obvious one which is missing. Things like curl vs invoke-webrequest if you know curl and you don't need any other functionality then using what you would use in another shell is fine.

I am not sure why Set should be considered missing. PowerShell is not cmd.exe, it does not manage its variables in the same way, and neither should it pretend to. Set is already included in Approved Verbs for PowerShell Commands so any other interpretation would be more confusing.

curl is not an alias anymore so should happily work even on Windows.

PS> Get-Command curl

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     curl.exe                                           8.0.1.0    C:\WINDOWS\system32\curl.exe

Linux

PS> Get-Command curl

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     curl                                               0.0.0.0    /usr/bin/curl

rhubarb-geek-nz avatar Apr 19 '23 23:04 rhubarb-geek-nz

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.

Still a good addition to PowerShell that I don't think has been added yet.

sylveon avatar Nov 15 '23 02:11 sylveon

This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.