#!/bin/bash # record working dir OWD=$(pwd) # chdir to docroot cd $(dirname $0)/../public function addrefpath { path="$1" if test ${path:0:1} != "/" then REFPATH="$OWD/$path$REFPATH" else REFPATH="$path$REFPATH" fi } # override REFPATH if test $# -gt 0; then REFPATH="" addrefpath "$1" shift while test $# -gt 0; do addrefpath "$1:" shift done fi if test -z "$REFPATH" then printf "Usage:\n\t%s [refpath] ...\n\n" "$(basename $0)" printf "Parameters:\n" printf "\trefpath path to a markdown reference tree or a colon separated\n" printf "\t list of those (optional, multiple)\n\n" printf "Environment:\n" printf "\tREFPATH colon separated list of refpaths\n\n" printf "Examples:\n" printf "\t\$ REFPATH=refs/foo:refs/bar ./bin/cli-server\n\n" printf "\t\$ ./bin/cli-server refs/*\n\n" printf "\tAt least one refpath must be given, either through the environment\n" printf "\twith REFPATH or as command line argument.\n\n" exit 1 fi export REFPATH for p in {8000..8100}; do ${PHP:-php} -S localhost:$p -t . index.php && break done