Skip to content

Instantly share code, notes, and snippets.

@hroptatyr
Created November 28, 2012 09:33
Show Gist options
  • Save hroptatyr/4160153 to your computer and use it in GitHub Desktop.
Save hroptatyr/4160153 to your computer and use it in GitHub Desktop.
fifoify -- replace every .xz file on the command line by a fifo with an xz process attached
#!/bin/sh
new_args="${1}"
shift
for arg; do
case "${arg}" in
(*".xz")
repl="${arg%.xz}"
if ! test -e "${repl}"; then
mkfifo "${repl}"
fi
if test -p "${repl}"; then
fifos="'${repl}' ${fifos}"
new_args="${new_args} '${repl}'"
xz -dc "${arg}" > "${repl}" &
pids="${!} ${pids}"
else
new_args="${new_args} '${arg}'"
fi
;;
(*)
new_args="${new_args} '${arg}'"
;;
esac
done
eval "${new_args}"
for i in ${pids}; do
wait "${i}"
done
eval "rm -f -- ${fifos}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment