Created
August 3, 2018 18:37
-
-
Save HumanEquivalentUnit/c00db7ceb2fdba17931145e27c71b0ee to your computer and use it in GitHub Desktop.
Bodge-add binary literal number support to PowerShell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ExecutionContext.InvokeCommand.CommandNotFoundAction = { | |
param($Name,[System.Management.Automation.CommandLookupEventArgs]$CommandLookupArgs) | |
$CommandLookupArgs.CommandScriptBlock = { | |
if ($CommandLookupArgs.CommandName -match '(?<binary>1[10]*)b$') | |
{ | |
[convert]::ToInt32($matches['binary'], 2) | |
} | |
}.GetNewClosure() | |
} | |
1b | |
10b | |
11b | |
100b | |
101b | |
110b | |
111b | |
1000b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment