#!/bin/sh # Count lines of code in a git repo (fetching from a URL into a tmp dir first, if needed) if [ -n "$1" ] && ! [ -e "$1" ]; then tmpdir="$(mktemp -d /tmp/git-cloc.XXXXXX)" trap 'rm -rf "$tmpdir"' EXIT git clone --depth 1 "$1" "$tmpdir" cloc "$tmpdir" else cloc --vcs=git fi