I've got a script like the following:
flag=false
# Do a bunch of stuff that might set flag to true.
if [[ "$flag" == "true" ]]; then
command \
| pipe_command_a \
| pipe_command_b \
| pipe_command_c \
| pipe_command_d \
> "${output_path}"
else
command \
| pipe_command_a \
| pipe_command_c \
| pipe_command_d \
> "${output_path}"
fi
The only difference between flag being true or false makes is that pipe_command_b may not be run. Is there a way to collapse this so that I don't have to repeat all of the common stuff?