bin: Create and use new logging functions

These write errors to stderr and avoid unintentional backslash escape
processing in their arguments.
This commit is contained in:
Richard Hansen 2020-05-14 17:28:53 -04:00
parent a87a9bb63b
commit 5462d2109c
4 changed files with 49 additions and 54 deletions

View file

@ -1,5 +1,10 @@
#!/bin/sh
pecho() { printf %s\\n "$*"; }
log() { pecho "$@"; }
error() { log "ERROR: $@" >&2; }
fatal() { error "$@"; exit 1; }
# Move to the folder where ep-lite is installed
cd $(dirname $0)
@ -23,8 +28,7 @@ if [ "$(id -u)" -eq 0 ] && [ $ignoreRoot -eq 0 ]; then
read rocks
if [ ! "$rocks" = "Etherpad rocks my socks" ]
then
echo "Your input was incorrect"
exit 1
fatal "Your input was incorrect"
fi
fi
@ -32,7 +36,7 @@ fi
bin/installDeps.sh "$@" || exit 1
# Move to the node folder and start
echo "Started Etherpad..."
log "Starting Etherpad..."
SCRIPTPATH=$(pwd -P)
exec node "$SCRIPTPATH/node_modules/ep_etherpad-lite/node/server.js" "$@"