Repository navigation
"Sort" keyword missing in verb-noun pattern - #80
Conversation
"Sort" keyword missing in verb-noun pattern causing "Sort-Object" to not being highlighted correctly.
|
Good stuff! I'll take this off my list. |
| <string>Verb-Noun pattern:</string> | ||
| <key>match</key> | ||
| <string>(?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b</string> | ||
| <string>(?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b</string> |
There was a problem hiding this comment.
I actually don't see Build or Deploy on this list (these were added in PS Core 6), would you mind adding them?
There was a problem hiding this comment.
I think those are the only 2... might be worth doing a Get-Verb to double check.
There was a problem hiding this comment.
Quick 'n dirty: z:\> (Get-Verb).Verb -join '|'
There was a problem hiding this comment.
Sort isn't an approved verb 😱
Result:
Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write
That explains why it's not in the list in the first place.
p.s. needed to alpha-sort the results of that line Nick James (@omniomi) just to share knowledge
There was a problem hiding this comment.
Yes, oddly Sort is missing from approved verbs in PS, but I think we should add it anyways? I'll also add Deploy and Build verbs.
There was a problem hiding this comment.
ms714428 lists sort under "These verbs are used by the Windows PowerShell language, or by special case cmdlets provided by Windows PowerShell." (emphasis mine.) So while not in the approved list "it is known." Where, Tee, Group, Format, and ForEach are in the same list so won't show up when you do Get-Verb either but should be included.
There was a problem hiding this comment.
If I used (Get-Command -All -Verb * | sort verb -Unique).verb -join '|' I get this list:
Add|Approve|Assert|Backup|BackupToAAD|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Flush|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Pop|Protect|Publish|Push|Read|Receive|Register|Remove|Rename|Repair|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Sort|Split|Start|Step|Stop|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Where|Write
There was a problem hiding this comment.
Should I add all verbs from your list or only reserved verbs mentioned in ms714428? I am asking because some verbs on your list are neither on approved or reserved verb list.
Add *Build* and *Deploy* to verb-noun pattern
| <string>Verb-Noun pattern:</string> | ||
| <key>match</key> | ||
| <string>(?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b</string> | ||
| <string>(?:(\p{L}|\d|_|-|\\|\:)*\\)?\b(?i:Add|Approve|Assert|Backup|Block|Build|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Deploy|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Mount|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Write)\-.+?(?:\.(?i:exe|cmd|bat|ps1))?\b</string> |
There was a problem hiding this comment.
Few more to add, Tee as in Tee-Object, ForEach as in ForEach-Object, and Flush as in Flush-Volume. That should do it for now. Eventually the whole thing should be reworked to not rely on approved verbs (that's PSScriptAnalyzer's problem.) Keep it this way for now.
* Remove **Sort** from approved verb-noun pattern * Add **sort-object** & **tee-object** to builtin cmdlets with reserved verbs section *Note: I did not add **Flush** verb (i.e **Flush-Volume**) as it is alias for **Write-FileSystemCache** cmdlet*
|
I have tested Kris Borowinski (@kborowinski)'s version and everything highlights without clobbering Once we're all done squashing bugs we'll need to do an overall review of this section. There's some duplication elsewhere in the spec for some of the listed functions and questions about scoping but that's for the cleanup phase ;D |
TylerLeonhardt
left a comment
There was a problem hiding this comment.
LGTM! Thanks for this 😀 look out for it in the next insider build.

"Sort" keyword missing in verb-noun pattern causing "Sort-Object" to not being highlighted correctly.