version.do (437B)
1 FALLBACKVER=${FALLBACKVER:-unknown} 2 LC_ALL=C 3 export LC_ALL 4 user=$(unalias ls >/dev/null 2>&1 || true; \ 5 command ls -ld . | awk '{print $3}') 6 e_user=$(id -un) 7 if [ -d .git ] && command -v git >/dev/null 2>&1; then 8 if [ "$e_user" = "$user" ]; then 9 git describe 2>/dev/null | sed 's/^v//' >$3 10 else 11 su "${user}" -c 'git describe' 2>/dev/null | sed 's/^v//' >$3 12 fi 13 else 14 printf "%s\n" "$FALLBACKVER" >$3 15 fi 16 redo-always 17 redo-stamp <$3