Commit 0ae2ae8d authored by Vincent Pelletier's avatar Vincent Pelletier

Inline helper to simplify usage.

parent 98141ebe
#!/bin/sh #!/bin/bash
usage() { usage() {
echo "Usage:" echo "Usage:"
echo " find [...] -print0 | $0 \\" echo " find [...] -print0 | $0 \\"
echo " path_to_helper parallelism state_dir out_file command [arg1 [...]]" echo " parallelism state_dir out_file command [arg1 [...]]"
echo "Reads filenames to process from stdin, null-delimited." echo "Reads filenames to process from stdin, null-delimited."
} }
...@@ -11,12 +11,6 @@ if [ $1 = '-h' -o $1 = '--help' ]; then ...@@ -11,12 +11,6 @@ if [ $1 = '-h' -o $1 = '--help' ]; then
exit 0 exit 0
fi fi
HELPER=$1
if [ ! -x "$HELPER" ]; then
echo "$HELPER cannot be executed"
exit 1
fi
shift
PARALLELISM=$1 PARALLELISM=$1
shift shift
STATE_DIR=$1 STATE_DIR=$1
...@@ -30,5 +24,6 @@ if [ $# -eq 0 ]; then ...@@ -30,5 +24,6 @@ if [ $# -eq 0 ]; then
exit 1 exit 1
fi fi
xargs -0 -r -n 1 -P $PARALLELISM -I "@FILE@" "$HELPER" "@FILE@" "$STATE_DIR" "$@" # XXX: any simpler way ?
xargs -0 -r -n 1 -P $PARALLELISM -I "@FILE@" -- "$SHELL" -c 'INFILE="$1";shift;STATE_DIR="$1";shift;echo -n .;"$@" -Q --format json --out "$STATE_DIR/$(sed s:/:@:g <<< "$INFILE").json" "$INFILE"' "$0" "@FILE@" "$STATE_DIR" "$@"
"$@" --out "$OUT_FILE" --state-file "$STATE_DIR"/* "$@" --out "$OUT_FILE" --state-file "$STATE_DIR"/*
#!/bin/bash
INFILE=$1
shift
STATE_DIR=$1
shift
echo -n '.'
exec "$@" -Q --format json --out "$STATE_DIR/$(sed s:/:@:g <<< "$INFILE").json" "$INFILE"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment