Skip to content

Instantly share code, notes, and snippets.

@zachriggle
Created Nov 6, 2021
Embed
What would you like to do?
#!/usr/bin/env zsh
autoload -U zargs
staging=$(mktemp -d)
input=( 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 )
wrapper1 () {
"double" "${input[$1]}" > "$staging/$1"
}
wrapper2 () {
"$1" "${input[$2]}" > "$staging/$2"
}
double () {
echo $(( $1 * 2 ))
sleep 0.5
}
# Works
zargs -P12 -n1 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -- wrapper1
# Does not work --> zrgs: argument list too long
# zargs -P12 -n1 -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -- wrapper2 double
for i in {1..${#input}}; do
echo "input[$i] --> $(< $staging/$i)"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment