'No operation command
With Bash, you have the command :
Null command. No effect; the command does nothing. Exit Status: Always succeeds.
Example
: 'foo'
Does PowerShell have something similar to this?
Solution 1:[1]
With the above example, the ForEach-Object
alias %
works
% 'foo'
Or
function : {}
: 'foo'
Or
[void] 'foo'
Solution 2:[2]
Another even shorter solution is to use the alias of Where-Object
which is ?
.
This command line does nothing (and succeeds):
? .
The trick is simply to pass a single-character argument so that the command does not fail and which has no special meaning in powershell.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | adamency |