[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Add new program: psub
From: |
Bo Borgerson |
Subject: |
[PATCH] Add new program: psub |
Date: |
Sun, 27 Apr 2008 21:02:06 -0400 |
Hi,
This program uses the temporary fifo management system that I built
for zargs to provide generic process substitution for arguments to a
sub-command.
This program has some advantages over the process substitution built
into some shells (bash, zsh, ksh, ???):
1. It doesn't rely on having a shell that supports built-in process
substitution.
2. By using descriptively named temporary fifos it allows programs
that include filenames in output or diagnostic messages to provide
more useful information than with '/dev/fd/*' inputs.
3. It supports `--files0-from=F' style argument passing, as well.
Examples:
Where in bash you might do:
$ uniq bigfile | tee >(wc -l > bigfile-uniq.count) | gzip -c > bigfile-uniq.gz
With psub you would do:
$ uniq bigfile | psub tee ">wc -l > bigfile-uniq.count" | gzip -c >
bigfile-uniq.gz
And where in bash you might do:
$ wc -l <(ls a) <(ls b)
2 /dev/fd/63
1 /dev/fd/62
3 total
With psub you could do:
$ psub wc -l "<ls a" "<ls b"
2 /tmp/psub25j3Al/ls a
1 /tmp/psub25j3Al/ls b
3 total
Or even:
$ find * -maxdepth 0 -type d | sed "s/^/<ls /" | tr '\n' '\0' | psub
wc -l --files0-from=-
2 /tmp/psubSZT8xC/ls a
5 /tmp/psubSZT8xC/ls autom4te.cache
1 /tmp/psubSZT8xC/ls b
20 /tmp/psubSZT8xC/ls build-aux
13 /tmp/psubSZT8xC/ls doc
3 /tmp/psubSZT8xC/ls gl
19 /tmp/psubSZT8xC/ls gnulib
269 /tmp/psubSZT8xC/ls gnulib-tests
648 /tmp/psubSZT8xC/ls lib
299 /tmp/psubSZT8xC/ls m4
203 /tmp/psubSZT8xC/ls man
3 /tmp/psubSZT8xC/ls old
121 /tmp/psubSZT8xC/ls po
345 /tmp/psubSZT8xC/ls src
49 /tmp/psubSZT8xC/ls tests
2000 total
The attached version doesn't include any `doc/' or `tests/' yet, but
should be functional enough to give a sense of usage. If this looks
like something that might be a useful addition to coreutils I'll be
happy to write some documentation and tests and resubmit.
Also available for fetch at:
$ git fetch git://repo.or.cz/coreutils/bo.git psub:psub
Thanks,
Bo
coreutils-psub.diff
Description: Text Data
- [PATCH] Add new program: psub,
Bo Borgerson <=