A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage.
Licensed under GNU/GPL v2.
An sh -c ...
command is started for each of the input commands; environment and current working directory are preserved.
NOTE: file descriptors are not
All commands will be executed, no matter which one fails. Return value will be the sum of exit values of each command.
It is suggested to use exec
if you want the shell-spawned process to subsitute each of the wrapping shells and be able to handle signals.
See also http://tldp.org/LDP/abs/html/process-sub.html
$ ldd coshell
not a dynamic executable
Thanks to Go language, this is a self-contained executable thus a perfect match for inclusion in an initramfs or any other project where you would prefer not to have too many dependencies.
Once you run:
go get github.com/gdm85/coshell
The binary will be available in your $GOPATH/bin
; alternatively, build it with:
make
Then copy the output bin/coshell
binary to your $PATH
, ~/bin
, /usr/local/bin
or any of your option.
Specify each command on a single line as standard input.
Example:
echo -e "echo test1\necho test2\necho test3" | coshell
Output:
test3
test1
test2
Order is not deterministic by default, but with option --deinterlace
or -d
all output will be buffered and afterwards
printed in the same chronological order as process termination.
If --halt-all
or -a
option is specified then first process to terminate unsuccessfully (with non-zero exit code) will cause
all processes to immediately exit (including coshell) with the exit code of such process.
The --master=n
or -m=n
option takes a positive integer number as the index of specified command lines to identify
which process "leads" the pack: when the process exits all neighbour processes will be terminated as well and its exit code
will be adopted as coshell exit code.
See examples/ directory.