summary refs log tree commit diff
path: root/pkgs/development/perl-modules/expression-generator/lib-cache.sh
blob: 7473e2d1c15ed0bd1239c302e47cc863700cceae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# 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}";
}