dimo414 / bash-cache

Transparent caching layer for bash functions; particularly useful for functions invoked as part of your prompt.
GNU General Public License v3.0
73 stars 4 forks source link

Eliminate the exit file #9

Closed dimo414 closed 3 years ago

dimo414 commented 6 years ago

Original report by Michael Diamond (Bitbucket: dimo414).


Since the exit code is a fixed-width value it could be written to the out or err files instead, rather than to a separate file. This would eliminate ~1/3rd of the file I/O per cache operation.

Initially reported in #5.

dimo414 commented 4 years ago

https://unix.stackexchange.com/a/176703/19157 offers a clever pattern. Coprocesses might also be useful, but were introduced in Bash 4.0.

dimo414 commented 3 years ago

bc::memoize uses roughly this technique, however now that bc::cache simply redirects the stdout/stderr files it's not possible to extract a value from either stream.