My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/pkgs/development/perl-modules/expression-generator/lib-cache.sh

18 lines
431 B

# First argument: command to run
# Second argument: cache name
# Third argument: argument to command
# Fourth argument: cache type
cached_output () {
cmd="$1";
basename="$2";
arg="$3";
ext="$4";
if ! [ -e "cache-${ext//./-}/${basename}.${ext}" ]; then
mkdir -p "cache-${ext//./-}";
$cmd $arg > "cache-${ext//./-}/${basename}.${ext}";
fi;
cat "cache-${ext//./-}/${basename}.${ext}";
}