-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Provide a syntax to call native binaries when its name is aliased #1975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
On Windows, it's common to use an extension, e.g. A full path (or relative path) is the most obvious way to invoke an external command, but we do have a syntax (admittedly obscure) if you don't know the path: & (Get-Command -CommandType Application gsn) The That said, I agree a better syntax is needed for Linux. |
@lzybkr How about “:gsn”? I am not sure whether this prefix is occupied... |
That would be a breaking change - admittedly unlikely to cause problems, but a breaking change nonetheless: function :gsn { 'in gsn' }
:gsn The above has worked since V1 - it likely wasn't intentional - I can't say for sure, I joined the team during V2. |
@lzybkr So, according to your code adding any functions are breaking because... its name may be used in a user’s script. |
What about |
The ability to use ":gsn" was intentional. Per POSIX, any valid file name character can be used in a command name (where the legal filename characters varying between file systems). |
Start-Process abc I guess this should work if you have proper file association, or Invoke-Item. If those are not available on PowerShell for *nix that's bad. |
Probably something like this could do the trick even without language changes (we'll need to add only one new simple command and a convenience alias): function Call-NativeCommand ($cmd) {
& (Get-Command -CommandType Application $cmd) @args
}
New-Alias ^ Call-NativeCommand After that you'll be able to do the following: $ New-Alias curl echo # ensure that curl is an alias for something
$ curl --version # the alias got called
--version
$ ^ curl --version # the real binary got called
curl 7.28.1 (i386-pc-win32) [...] Although I'm not sure how this will work with |
|
Hi, I hate to be that "updates" guy, but given the sheer amount of time and the abrupt drop-off in comms here (ie, nothing suggesting any show-stoppers etc), I can't tell if work has moved elsewhere without updating this issue, or if this is in fact the state of affairs still. (fwiw I think the latter is alright, though I'd love to then know if there's a way the community can help move this forward that y'all can advise on) |
WG-Engine discussed this today. We don't think the value of the proposed feature here meets the bar for making a potentially breaking language-level change. There are workarounds available that folks here have mentioned, and there are also arguments to be made about avoiding such name collisions in the first place whenever possible. Thanks for submitting this request, but ultimately we feel this is not something that we could accept as a language change. |
This issue has been marked as declined and has not had any activity for 1 day. It has been closed for housekeeping purposes. |
Like, if I have both
gsn
(as an alias) andgsn
(as a script on Linux with Shebang), the latter one is unaccessable (unless you provide its full path).The text was updated successfully, but these errors were encountered: