From 3a9651702fdc5d05dd29ca9163d06851b3dee0f9 Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sun, 1 Oct 2017 17:13:47 +0200 Subject: [PATCH] kodev: run with catchsegv by default (#3283) See https://github.com/koreader/koreader/issues/2878#issuecomment-326796777 Also fix `./kodev run -h` as alias for `--help` as it's always overwritten by `-h` in the sense of the much more important `--screen-height`. --- kodev | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/kodev b/kodev index ab4b7d0a0..3ee8b0dec 100755 --- a/kodev +++ b/kodev @@ -383,7 +383,13 @@ OPTIONS: screen_width=${VALUE} ;; -h | --screen-height) - screen_height=${VALUE} + # simple numeric check due to overlap between -h for help and height + if [ ! -z "${VALUE##*[!0-9]*}" ]; then + screen_height=${VALUE} + else + echo "${RUN_HELP_MSG}" + exit 0 + fi ;; -d | --screen-dpi) screen_dpi=${VALUE} @@ -410,7 +416,7 @@ OPTIONS: ;; esac ;; - -h | --help) + --help) echo "${RUN_HELP_MSG}" exit 0 ;; @@ -439,6 +445,12 @@ OPTIONS: gnuplot_wrapper "--parent $$" "reader.lua" fi + # run with catchsegv by default when it is available + # see https://github.com/koreader/koreader/issues/2878#issuecomment-326796777 + if command -v catchsegv >/dev/null; then + CATCHSEGV=$(which catchsegv) + fi + echo "[*] Running KOReader with arguments: $*..." pushd "${EMU_DIR}" && { if [ $# -lt 1 ]; then @@ -451,7 +463,7 @@ OPTIONS: RETURN_VALUE=85 while [ $RETURN_VALUE -eq 85 ]; do EMULATE_READER_W=${screen_width} EMULATE_READER_H=${screen_height} EMULATE_READER_DPI=${screen_dpi} \ - ./reader.lua -d "$args" + $CATCHSEGV ./reader.lua -d "$args" RETURN_VALUE=$? done } && popd || exit