You might think that this solution is just as hacky as the others, but I think it uses less memory than others (I am not an expert on the effectiveness of the shell script).
Bash code:
z=0 while read -r -n1 char; do z=1 break done < <(git ls-files --killed) [ $z != 0 ]
It uses a temporary variable instead of a temporary file, and I think that reading only works with one char at a time, but the git ls-files command can be fully executed.
It may not be much less ugly, but I think it can be at least more efficient.
source share