commit 9224afc09e969b1391f563efea6443e850d5d5d3 Author: slonkazoid Date: Sun Dec 29 00:45:07 2024 +0300 initial commit 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" +}