Begin, process, and end
A script or function often begins with comment-based help, followed by a param block, and then one or more of the named blocks may be used.
In a script or function, if none of the blocks are declared, content is automatically placed in the end block.
In a filter, if none of the blocks are declared, content is automatically placed in the process block. This is the only difference between a function and a filter.
The named blocks refer to the processing of a pipeline and therefore make the most sense if the command is working on pipeline input.
This difference in default block is shown in the following pipeline example. The function must explicitly declare a process block to use the $_ variable. The filter can leverage ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access