From 3368d3c81c1a561f9b7cdd1efd6a4dc547d191cd Mon Sep 17 00:00:00 2001 From: Doeke Zanstra Date: Tue, 28 Apr 2020 18:14:33 +0200 Subject: [PATCH] Implements issue #13 --- ok.sh | 11 ++++++++++- test/.ok | 19 +++++-------------- test/.ok-sh | 14 ++++++++++++++ test/utf_8/{.ok => .ok-sh} | 0 4 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 test/.ok-sh rename test/utf_8/{.ok => .ok-sh} (100%) diff --git a/ok.sh b/ok.sh index a50b862..dfd5a92 100755 --- a/ok.sh +++ b/ok.sh @@ -106,7 +106,7 @@ environment variables (for internal use): if [ -z ${_OK_VERBOSE+x} ]; then local verbose=1; else local verbose=$_OK_VERBOSE; fi # handle command line arguments now - local ok_file=".ok" + local ok_file="" local args # Make sure no double space is added if [[ -z "$*" ]]; then args="ok" @@ -147,6 +147,15 @@ environment variables (for internal use): fi shift done + # When no ok_file supplied, check if a default one is readable + if [[ -z "$ok_file" ]]; then + for f in .ok-sh .ok; do + if [[ -r "$f" ]]; then + ok_file="$f" + break # found + fi + done + fi if [[ $cmd == usage ]]; then _ok_cmd_usage "$usage_error" || return $? diff --git a/test/.ok b/test/.ok index 870776d..b80faac 100644 --- a/test/.ok +++ b/test/.ok @@ -1,14 +1,5 @@ -# Control what python to use -_OK__PATH_TO_PYTHON=$(command -v python) # set python2 -_OK__PATH_TO_PYTHON=$(command -v python3) # set python3 -unset _OK__PATH_TO_PYTHON #test if this works too -echo "Path to python: '$_OK__PATH_TO_PYTHON'" # check path -$_OK__PATH_TO_PYTHON --version # check python version -# Control encoding or not -echo "Python IO Encoding: ${PYTHONIOENCODING:--=not-set=-}" -export PYTHONIOENCODING="UTF-8" # only python3 will choke on non-UTF-8, when this is set -unset PYTHONIOENCODING # nonetheless, python will treat everything as ASCII -# Go to the test cases -cd iso_latin_1 -cd mac_os_roman -cd utf_8 +# This `.ok` file should not be shown +# because `.ok-sh` should be used. +# `.ok-sh` takes precedence over `.ok` when both exists +cat .ok +cat .ok-sh diff --git a/test/.ok-sh b/test/.ok-sh new file mode 100644 index 0000000..870776d --- /dev/null +++ b/test/.ok-sh @@ -0,0 +1,14 @@ +# Control what python to use +_OK__PATH_TO_PYTHON=$(command -v python) # set python2 +_OK__PATH_TO_PYTHON=$(command -v python3) # set python3 +unset _OK__PATH_TO_PYTHON #test if this works too +echo "Path to python: '$_OK__PATH_TO_PYTHON'" # check path +$_OK__PATH_TO_PYTHON --version # check python version +# Control encoding or not +echo "Python IO Encoding: ${PYTHONIOENCODING:--=not-set=-}" +export PYTHONIOENCODING="UTF-8" # only python3 will choke on non-UTF-8, when this is set +unset PYTHONIOENCODING # nonetheless, python will treat everything as ASCII +# Go to the test cases +cd iso_latin_1 +cd mac_os_roman +cd utf_8 diff --git a/test/utf_8/.ok b/test/utf_8/.ok-sh similarity index 100% rename from test/utf_8/.ok rename to test/utf_8/.ok-sh