mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 15:22:59 +01:00
57b496ea98
I've tried to be consistent, using four or eight spaces to line up with existing code.
18 lines
431 B
Bash
18 lines
431 B
Bash
|
|
# 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}";
|
|
}
|