I'm trying to figure out how to wait for a command to complete, and then pipe stdin to stdout. I'm on a mac, but I think my question is more about how to wait for a process to complete and pipe the output then anything to do with a mac.
I've noticed that on the mac, I can run a few
say commands together, and they wait for each phrase to be fully spoken before starting the next one, if I use the
&& operator to join them up.
$ say "stage 1" && say "stage 2"
Here's where the real use case is - I've got a bash script that I'd like to have it just pass stdin to stdout, after it finishes saying something.
$ cat /etc/passwd | say_and_pass "stage 1" | grep -v test | say_and_pass "stage 2"
So conceptually, this would say aloud, "stage 1", then immediately say "stage 2", and then dump the grepped contents of
/etc/password to stdout.
My initial crack at the
say_and_pass script is this:
#!/usr/bin/env bash OUT="$*" say "$OUT" && cat
But it doesn't seem to work ;-)
EDIT: I changed the example above to use
say_and_pass "stage2" as the final command, which is needed for my solution to work...