Blame SOURCES/parallel_xz.sh

b1b780
#!/bin/sh
b1b780
# Reads filenames on stdin, xz-compresses each in place.
b1b780
# Not optimal for "compress relatively few, large files" scenario!
b1b780
b1b780
# How many xz's to run in parallel:
b1b780
procgroup=""
b1b780
while test "$#" != 0; do
b1b780
	# Get it from -jNUM
b1b780
	N="${1#-j}"
b1b780
	if test "$N" = "$1"; then
b1b780
		# Not -j<something> - warn and ignore
b1b780
		echo "parallel_xz: warning: unrecognized argument: '$1'"
b1b780
	else
b1b780
		procgroup="$N"
b1b780
	fi
b1b780
	shift
b1b780
done
b1b780
b1b780
# If told to use only one cpu:
b1b780
test "$procgroup" || exec xargs -r xz
b1b780
test "$procgroup" = 1 && exec xargs -r xz
b1b780
b1b780
# xz has some startup cost. If files are really small,
b1b780
# this cost might be significant. To combat this,
b1b780
# process several files (in sequence) by each xz process via -n 16:
b1b780
exec xargs -r -n 16 -P $procgroup xz