1234567891011121314151617181920 |
- #!/bin/sh --
- set -ue
- GLOB="${1:?glob pattern not specified}"
- shift
- : "${1:?command not specified}"
- trap 'echo "glob failed" 1>&2; exit 1' USR1
- main="${$}"
- (
- eval "set -- ${GLOB}"
- [ "${#}${GLOB}" != "1${GLOB}" ] || {
- kill -s USR1 -- "${main}"
- exit
- }
- for path; do printf '%s\0' "${path}"; done
- ) | xargs -0o -I% -P1 -- "${@}"
|