Skip to content
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

With Windows PowerShell, complains about missing xclip the first it's used if StrictMode is in effect #5

Closed
sba923 opened this issue Oct 8, 2018 · 2 comments

Comments

@sba923
Copy link

sba923 commented Oct 8, 2018

My PowerShell profile invokes

Set-StrictMode -Version Latest

As a side effect, the first time I use the module in a PS session (i.e. when the module gets auto-loaded), I get a message telling me that "xclip" is not installed... whereas I'm running Windows PowerShell 5.1 on Windows 10 ;-)

Here's the culprit: CheckPrereqs.ps1 tests the value of $IsLinux, which doesn't exist in Windows PowerShell. If StrictMode is not in effect, the test works, because $IsLinux silently evaluates to $null.

But if StrictMode is in effect, the test fails...

mklement0 added a commit that referenced this issue Oct 9, 2018
  * [fix] for #5: The prerequisites-check script now runs without error even when `Set-StrictMode -Version Latest` is in effect in the caller's scope.
@mklement0
Copy link
Owner

Good find, and thanks for the detailed pointers - just published v0.1.7 with a fix.

As an aside:

Modules that don't have ScriptsToProcess entries won't be affected, but I expect that many a script will break if you spring a global Set-StrictMode -Version Latest on it (unless these scripts all manage their own strict mode).

There is a - languishing - RFC that proposes introduction of a lexical strict mode, that would avoid such problems - see https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0003-Lexical-Strict-Mode.md

@sba923
Copy link
Author

sba923 commented Oct 9, 2018

Fix tested with Windows PowerShell 5.1 and PowerShell Core 6.1.

Good job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants