#!/usr/bin/dash # This script requires a shell supporting the ${var##pattern} syntax. # It is supported by at least dash and bash, however not by busybox. # # The following environment variables can be used to retrieve the # configuration of the repository for which this script is called: # CGIT_REPO_URL ( = repo.url setting ) # CGIT_REPO_NAME ( = repo.name setting ) # CGIT_REPO_PATH ( = repo.path setting ) # CGIT_REPO_OWNER ( = repo.owner setting ) # CGIT_REPO_DEFBRANCH ( = repo.defbranch setting ) # CGIT_REPO_SECTION ( = section setting ) # CGIT_REPO_CLONE_URL ( = repo.clone-url setting ) # Store filename and extension in local variables BASENAME="$1" EXTENSION="${BASENAME##*.}" # Use .txt as a sensible default format [ "${BASENAME}" = "${EXTENSION}" ] && EXTENSION=txt [ -z "${EXTENSION}" ] && EXTENSION=txt # Map Makefile and Makefile.* to .mk [ "${BASENAME%%.*}" = "Makefile" ] && EXTENSION=mk # This is for version 3 and above of the "highlight" package exec highlight --force -f -I -O xhtml -S "$EXTENSION" 2>/dev/null