Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Helps the shell sometimes...
C
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
src
tests
Makefile
README
test-binyes.sh
test.c
test.sh

README

FAQ
- Aren't there better...
    Yes, but I wanted to try out CUSE myself.
    What better argument is there to create this piece of code anyway?

Anyway: the "arent't there better...' FAQ:
- Aren't there better alternatives? Like the `yes' command?
    `yes' isn't suitable for binary data.

- Then wouldn't a `binyes' which reads the pattern from stdin
  and then 'yesses' it to stdout be still better?
    Sometimes. Many shells support syntax like: exec 7<>some_file
    But bash for example, unlike plan9 rc, does not do: exec 7<>(cmd)
    Bash4 may have the 'coproc' feature for this, but it seems to be
    widely unknown, and: what about sh/dash/csh?
    I bet zsh can do the whole thing by itself though.

    Read tests/binyes-bash4.sh for a coproc example.

- `binyes' using FIFOs?
    Yes, if you create temporary FIFOs rather than using one FIFO for
    all, to avoid race conditions in opening the write and read ends.
    However it is generally uglier to use temporary files than simply
    opening a pipe - using /dev/pattern as a file, or binyes as a
    `coproc'.
    If you really do not have any 'exec' construct though, FIFOs are
    either ugly to use, or you use subshell constructs, in which case
    some local variables can be a pita to get out into the main
    process... read tests/binyes-fifo.sh
Something went wrong with that request. Please try again.