Reputation: 860
This program works great, but how do I go from supporting 2 files to supporting n
files using the same [un]named pipe approach?
some_command \
<(tar c --xattrs -C "$1" --pax-option="exthdr.name=%d/PaxHeaders/%f" . | xxd) \
<(tar c --xattrs -C "$2" --pax-option="exthdr.name=%d/PaxHeaders/%f" . | xxd)
Upvotes: 0
Views: 137
Reputation: 531135
Rather than using the process substitution syntax, create the named pipes explicitly. (Process substitution is a transient construct; you can't create them one at a time to save up for later use.)
declare -a pipes
for arg in "$@"; do
new_pipe_name=pipe$((++i))
pipes+=( "$new_pipe_name" )
mkfifo "$new_pipe_name"
tar c --xattrs -C "$arg" --pax-option="exthdr.name=%d/PaxHeaders/%f" . |
xxd > "$new_pipe_name" &
done
mycommand "${pipes[@]}"
rm "${pipes[@]}"
Upvotes: 2