Commits

filiped committed cb48fc5

Use tac by default for reverse output (if available)

Comments (0)

Files changed (1)

 # Use newline as a field separator
 IFS=$(echo -en "\n\b")
 
+# Use tac if available, otherwise tail with the possibly-not-always-available
+# -r flag (for reverse output)
+TAC=$(which tac || echo 'tail -r')
+
 for line in $(git for-each-ref ${GIT_OPTS} refs/remotes --format="%(authordate:relative)|%(objectname:short)|%(authorname)|%(refname:short)|%(subject)" --sort="-authordate"); do
     fields=(`echo $line | tr "|" "\n"`)
     printf "${date_format}%15s${reset} ${commit_id_format}%s${reset} - ${author_format}[%s]${reset} (${ref_name_format}%s${reset}): %s\n" ${fields[*]}
-done | tail -r # reverse sort the output to show the newest entry last
+done | $TAC # reverse sort the output to show the newest entry last