https://github.com/sjmulder/within
Run a command in other directories
https://github.com/sjmulder/within
c cli shell unix
Last synced: 22 days ago
JSON representation
Run a command in other directories
- Host: GitHub
- URL: https://github.com/sjmulder/within
- Owner: sjmulder
- License: bsd-2-clause
- Created: 2018-11-02T21:49:43.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-07-25T23:46:10.000Z (almost 4 years ago)
- Last Synced: 2025-04-11T00:41:53.667Z (22 days ago)
- Topics: c, cli, shell, unix
- Language: C
- Size: 33.2 KB
- Stars: 10
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
within
======
[](
https://builds.sr.ht/~sjmulder/within)Run a command in other directories:
**within** [**-j** *jobs*] *directories* **-** *command*
Description
-----------
Runs the given *command* in all given *directories*,
prepending directory names to output:$ within msort trickle - make clean
msort: rm -f *.o msort
trickle: rm -f trickle trittyWhen a single directory is given the **--** may be omitted:
$ within code/msort git status
code/msort: nothing to commit, working tree cleanThe **-j** option specifies how many commands may be run simultaneously.
The default is 1.Implementation
--------------
Based around a select() event loop. As many jobs are started as **-j** allows
(1 by default), forking, descending into the given directory and executing
the command. For each job, both standard output and standard error are
redirected to a pipe that's read by a 'piper' which adds the 'directory:'
prefixes to the output. These pipers are effectively coroutines.The event loop waits for finished jobs, starting new ones if there are
directories left, and for data on the pipes.The select() specific code should be fairly easy to swap out. Point in
case, originally kqueue was used.Running
-------
Should work with any Unix, including Linux and macOS.Mac users can install from
[my Homebrew tap](https://github.com/sjmulder/homebrew-tap)brew install sjmulder/tap/within
To compile, install and uninstal from source:
make
make install [DESTDIR=] [PREFIX=/usr/local] [MANPREFIX=PREFIX/man]
make uninstall [DESTDIR=] [PREFIX=/usr/local] [MANPREFIX=PREFIX/man]Author
------
Sijmen J. Mulder ()