Ben Chuanlong Du's Blog

It is never too late to learn.

Preferred Python Version in Shebang

Things on this page are fragmentary and immature notes/thoughts of the author. Please read with your own judgement!

#!/bin/sh
''''which python2 >/dev/null 2>&1 && exec python2 "$0" "$@" # '''
''''which python  >/dev/null 2>&1 && exec python  "$0" "$@" # '''
''''exec echo "Error: I can't find python anywhere"         # '''

Reference

https …