2008-06-02 10:21:38 +02:00
|
|
|
|
|
|
|
# First argument: command to run
|
|
|
|
# Second argument: cache name
|
|
|
|
# Third argument: argument to command
|
|
|
|
# Fourth argument: cache type
|
|
|
|
cached_output () {
|
2021-11-14 03:54:33 +01:00
|
|
|
cmd="$1";
|
|
|
|
basename="$2";
|
|
|
|
arg="$3";
|
|
|
|
ext="$4";
|
2008-06-02 10:21:38 +02:00
|
|
|
|
2021-11-14 03:54:33 +01:00
|
|
|
if ! [ -e "cache-${ext//./-}/${basename}.${ext}" ]; then
|
|
|
|
mkdir -p "cache-${ext//./-}";
|
|
|
|
$cmd $arg > "cache-${ext//./-}/${basename}.${ext}";
|
|
|
|
fi;
|
2008-06-02 10:21:38 +02:00
|
|
|
|
2021-11-14 03:54:33 +01:00
|
|
|
cat "cache-${ext//./-}/${basename}.${ext}";
|
|
|
|
}
|