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

Support binaries in addition to functions #24

Closed vemv closed 3 years ago

vemv commented 3 years ago

Hi!

I'm interested in using this project. However I'm a zsh user. I noticed https://github.com/dimo414/bash-cache/issues/16 .

Indeed it seems a hassle to port scripts, so I thought - why not make bc::cache additionally accept filenames denoting a script when func is not a function?

I think that would be it - would you be willing to give it a shot?

Would gladly provide feedback afterwards.

Thanks - V

dimo414 commented 3 years ago

Note that you can define trivial functions that delegate to commands and cache that, via the command builtin:

ls() { command ls "$@"; } && bc::cache ls 1m 10s PWD

This is what I would generally recommend.

Supporting arbitrary binaries is tricky because they can be referenced multiple ways; e.g. /path/to/foo, ./foo (if in /path/to), and foo (if PATH is configured properly) may all refer to the same binary. Not impossible to address but it's the sort of problem that may be easier to pass off to the user.

I'd love to support zsh (though we'd have to do #11 if we did so 😄), but I have no plans to drive that at the moment. I'd be happy to work with someone interested in contributing support though.

vemv commented 3 years ago

Thanks for the response!

Had forgotten about this one, sorry.

I hacked some lightweight form of caching without delegating it to a library. It seemed enough for my needs.

dimo414 commented 3 years ago

As an update here, I'm in the process of publishing bkt, a standalone binary that's spiritually similar to bash-cache but intended for subprocesses instead of shell functions. If you'd like to try it out I'd welcome any feedback.

vemv commented 3 years ago

Cheers! Starred