I have a series of commands chained together with pipes:
should_create_one_line | expects_one_line
The first command should_create_one_line
should produce an output that only has one line, but under strange circumstances it is possible for the output to be multiline or empty.
I would like to add a step in between these two, validate_one_line
:
should_create_one_line | validate_one_line | expects_one_line
If its input contains exactly 1 line then validate_one_line
will simply output its input. If its input contains more than 1 line or is empty then validate_one_line
should cause the whole sequence of steps to stop and return an error code.
What command can I use for validate_one_line
?