Title: PowerShell needs a way to hide commands which won't work · Issue #1998 · PowerShell/PowerShell · GitHub
Open Graph Title: PowerShell needs a way to hide commands which won't work · Issue #1998 · PowerShell/PowerShell
X Title: PowerShell needs a way to hide commands which won't work · Issue #1998 · PowerShell/PowerShell
Description: For example: Set-ExecutionPolicy. This command should simply not exist on Linux. Rather than throwing RuntimeErrorException terminating errors, I would prefer to get a command-not found, because that's something I can test for ahead of t...
Open Graph Description: For example: Set-ExecutionPolicy. This command should simply not exist on Linux. Rather than throwing RuntimeErrorException terminating errors, I would prefer to get a command-not found, because th...
X Description: For example: Set-ExecutionPolicy. This command should simply not exist on Linux. Rather than throwing RuntimeErrorException terminating errors, I would prefer to get a command-not found, because th...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/1998
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PowerShell needs a way to hide commands which won't work","articleBody":"For example: `Set-ExecutionPolicy`. This command should simply _not exist_ on Linux. Rather than throwing `RuntimeErrorException` _**terminating** errors_, I would prefer to get a command-not found, because that's something I can test for _ahead of time_.\n\nYears of developing for moving targets on the web has taught us that the right way to avoid features that don't exist is to **test for the feature**, and _not_ for the underlying OS, Architecture, or software version, because you never know when someone's going to finally figure out how to implement something.\n\nIf non-functioning commands are not **hidden**, there is no easy, fast way for scripts to test for whether commands will work -- you have to run them and catch the exception. However, many scripters will _instead_ write incorrect conditional code _based on the PSEdition_ (or operating system sniffing, but currently that's not even in `$PSVersionTable` #1997) which will prevent them from using the feature in the case where it's added later on.\n\nIn general, when a (core) module exposes a command (functioning or not), it's more difficult for _another_ module to provide an implementation -- I know we can't anyway in this particular example, but that's the problem with picking examples ;-)\n## Suggestion: This should be exposed in the manifest.\n\nI would like an easy way to identify commands that should be exported _based on **PSEdition**, **PSVersion**, **OS**, or **Architecture**_ from the module manifest.\n\nI don't want to have to wrap binary modules in script modules to put conditional Export-ModuleManifest statements in ... especially since putting the _right_ values in the manifest for exported cmdlets is vital to discoverability.\n\nOne thought is to allow specific module manifests for platforms, like `MyModule.Core-Linux.psd1` or something -- this would provide solutions to other design problems as well (like loading the right binary assemblies).\n","author":{"url":"https://github.com/Jaykul","@type":"Person","name":"Jaykul"},"datePublished":"2016-08-21T19:05:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":12},"url":"https://github.com/1998/PowerShell/issues/1998"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:a1c4304d-a946-7742-b79d-f5f4dca0d47a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E232:234BE7:A1FBB5:D9DFDA:6A5296DD |
| html-safe-nonce | 4d6289aa4b9d90aac9a9a9e63ed92297827b03f2392ff64bc343905c78f8df08 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjMyOjIzNEJFNzpBMUZCQjU6RDlERkRBOjZBNTI5NkREIiwidmlzaXRvcl9pZCI6IjgxMjAwNzg4ODU0MzE5NzM1OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0353fb81d5acc0a0a03930c22115272f4e0974118224ed3e6a48c3fee06ccafe |
| hovercard-subject-tag | issue:172335609 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/1998/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2e06f95003418c0e13615c85a890479dbd50d803f57d03c64b2b417da62a6f18/PowerShell/PowerShell/issues/1998 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2e06f95003418c0e13615c85a890479dbd50d803f57d03c64b2b417da62a6f18/PowerShell/PowerShell/issues/1998 |
| og:image:alt | For example: Set-ExecutionPolicy. This command should simply not exist on Linux. Rather than throwing RuntimeErrorException terminating errors, I would prefer to get a command-not found, because th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Jaykul |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width