1
2# First argument: command to run
3# Second argument: cache name
4# Third argument: argument to command
5# Fourth argument: cache type
6cached_output () {
7 cmd="$1";
8 basename="$2";
9 arg="$3";
10 ext="$4";
11
12 if ! [ -e "cache-${ext//./-}/${basename}.${ext}" ]; then
13 mkdir -p "cache-${ext//./-}";
14 $cmd $arg > "cache-${ext//./-}/${basename}.${ext}";
15 fi;
16
17 cat "cache-${ext//./-}/${basename}.${ext}";
18}