mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-02 03:43:06 +00:00
57b496ea98
I've tried to be consistent, using four or eight spaces to line up with existing code.
19 lines
431 B
Bash
19 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}";
|
|
}
|