Dependency-free replacement for GNU parallel, perfect fit for usage in an initramfs.

coshell v0.2.5

A no-frills dependency-free replacement for GNU parallel, perfect for initramfs usage.

Licensed under GNU/GPL v2.

How it works

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 substitute each of the wrapping shells and be able to handle signals. See also http://tldp.org/LDP/abs/html/process-sub.html Alternatively, you can use --shell="" to force the usage of no shell (see description in the options section).

Self-contained

$ 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.

Installation

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.

Usage

Specify each command on a single line as standard input.

Example:

echo -e "echo test1\necho test2\necho test3" | coshell

Output:

test3
test1
test2

sequence length option

By specifying a sequence length greater than 1 it is possible to group commands in sequences. Each group of commands will be executed sequentially.

deinterlace option

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 your input.

shell

It is possible to specify a custom shell prefix or no shell at all (--shell=""); in such case, commands will be split according to /bin/sh's word-splitting rules. It supports backslash-escapes, single-quotes, and double-quotes. Notably it does not support the $'' style of quoting. It also doesn't attempt to perform any other sort of expansion, including brace expansion, shell expansion, or pathname expansion.

If the given input has an unterminated quoted string or ends in a backslash-escape an error is returned.

halt-all option

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.

master option

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.

Examples

See examples/ directory for examples of various use-cases.

Similar Resources

Disk usage analyzer with console interface written in Go

Disk usage analyzer with console interface written in Go

Gdu is intended primarily for SSD disks where it can fully utilize parallel processing. However HDDs work as well, but the performance gain is not so huge.

Jan 7, 2023

Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...

Integrated console application library, using Go structs as commands, with menus, completions, hints, history, Vim mode, $EDITOR usage, and more ...

Gonsole - Integrated Console Application library This package rests on a readline console library, (giving advanced completion, hint, input and histor

Nov 20, 2022

Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically

Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically

Redis inventory is a tool to analyse Redis memory usage by key patterns and displaying it hierarchically. The name is inspired by "Disk Inventory X" tool doing similar analysis for disk usage.

Dec 11, 2022

A cli that shows a GitHub-like language usage statistics bar.

A cli that shows a GitHub-like language usage statistics bar.

barley A cli that shows a GitHub-like language usage statistics bar. barley analyses the programming languages used in a directory and creates a used

Jan 8, 2022

Basic usage of Vecty framework examples.

vecty-examples Basic usage of Vecty framework examples. Instructions Change directory to the folder with the example you wish to run Run wasmserve. To

Jun 20, 2022

Simple Todo List - Wunderlist Replacement

Simple Todo List - Wunderlist Replacement

DoIT Todo List This is a simple todo-list made with Vue(frontend) and a simple webserver written in Go(backend). Note that this started out as a simpl

Oct 9, 2022

A lightweight replacement for the standard fmt package, reduces binary size by roughly 400kb in a hello world

console This is a lightweight replacement for the fmt package, reduces the binary size by roughly 400kb in a hello world program. Please note: This pa

Nov 7, 2021

word2text - a tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free

word2text - a tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free

This tool is to convert word documents (DocX) to text on the CLI with zero dependencies for free. This tool has been tested on: - Linux 32bit and 64 bit - Windows 32 bit and 64 bit - OpenBSD 64 bit

Apr 19, 2021

a Go language free and open-source document for learning from zero level

Go document a GO language free and open-source document for learning from zero level Please publish and collaborate OPEN-SOURCE Sections About go lang

Jan 8, 2023
Comments
  • Created support for substitution

    Created support for substitution

    Hey, if you're interested I've added basic support for doing this:

    echo -e "a\nb\nc" | go run coshell.go -p "echo ?{#} : ?{}" -e "?"
    0 : a
    1 : b
    2 : c
    

    Y'know, cause parallel can do that, though noisily.

  • make doesn't work

    make doesn't work

    Running make I find:

    ~/p/coshell ❯❯❯ make
    mkdir -p bin/
    ./emu-gopath.sh github.com/gdm85/coshell 'GOBIN="bin/" go install'
    cannot install, GOBIN must be an absolute path
    

    I tried editing that line to the following, which seemed to fix it (I can make this a pull request, but it seems very simple, and I don't know go well enough to be sure this is what I should do).

    ./emu-gopath.sh github.com/gdm85/coshell 'GOBIN="`pwd`/bin/" go install'
    
  • Cannot find cosh package with current package import

    Cannot find cosh package with current package import

    *Edit: The new non-relative path update caused an error. But it was just cause the application where i used it was not having the coshell package installed in the $GOPATH. Sorry for this first issue being a non-issue. :(

Related tags
M3u8-parallel-downloader - M3u8 parallel downloader with golang

m3u8-parallel-downloader Usage ./m3u8-parallel-downloader -input http://example.

Aug 12, 2022
Memorize and perfect your Go movements 🥋

Practice yourself, for heaven's sake, in little things; and thence proceed to greater. -- Epictetus Go katas Katas (形) are practiced in martial arts a

Dec 15, 2022
A Simple and Clear CLI library. Dependency free.
A Simple and Clear CLI library. Dependency free.

A Simple and Clear CLI library. Dependency free. Features Nested Subcommands Uses the standard library flag package Auto-generated help Custom banners

Jan 1, 2023
Dependency-Free Bencode Editor

rbEdit A statically compiled and dependency-free Bencode editor in Go, useful for command line use and scripts. Quick Start # Compile for linux arch:

Dec 28, 2022
Readline is a pure go(golang) implementation for GNU-Readline kind library
Readline is a pure go(golang) implementation for GNU-Readline kind library

A powerful readline library in Linux macOS Windows Solaris Guide Demo Shortcut Repos using readline Feedback If you have any questions, please submit

Jan 8, 2023
GNU coreutils remade in Go for RosetteOS

Rosebush GNU and POSIX coreutils remade in Go for RosetteOS Build To compile the Rosebush, simply make -B This will compile all the utils one by one.

Oct 4, 2021
GDScript Syntax Highlighting in GNU Nano

nano-gdscript GDScript Syntax Highlighting in GNU Nano. Updated regularly every minor updates. Contributions are welcomed Installation This is 100% fr

Dec 20, 2022
A Go implementation of gnu-coreutils programs

Go-Coreutils A Go implementation of gnu-coreutils programs (https://www.gnu.org/software/coreutils/manual/coreutils.html) Build and Run In the root di

Jan 15, 2022
A parallel downloader with resume capability
A parallel downloader with resume capability

Grozilla The Grozilla is a simple implementation that allows downloading of video,audio,package or zip files parallely and efficiently using light wei

May 5, 2022
Stack Up is a simple deployment tool that performs given set of commands on multiple hosts in parallel.
Stack Up is a simple deployment tool that performs given set of commands on multiple hosts in parallel.

Stack Up is a simple deployment tool that performs given set of commands on multiple hosts in parallel. It reads Supfile, a YAML configuration file, which defines networks (groups of hosts), commands and targets.

Jan 1, 2023