From 9224afc09e969b1391f563efea6443e850d5d5d3 Mon Sep 17 00:00:00 2001 From: slonkazoid Date: Sun, 29 Dec 2024 00:45:07 +0300 Subject: [PATCH] initial commit --- cash.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cash.sh diff --git a/cash.sh b/cash.sh new file mode 100644 index 0000000..4c0bd64 --- /dev/null +++ b/cash.sh @@ -0,0 +1,24 @@ +_try_cc() { + local out="$1" + shift + local infile + infile=$(mktemp --suffix .c) + cat > "$infile" + ccache hash_dir=false \ + "${CC:-cc}" -o "$out" "$infile" "$@" + code=$? + rm "$infile" || : + return $? +} + +cash() { + local out + out=$(mktemp) + _try_cc "$out" "$@" || { + code=$? + echo 'Error: compilation failed' >&2 + rm "$out" || : + return "$code" + } + echo "$out" +}