Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implements issue #13 #25

Merged
merged 1 commit into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion ok.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 $?
Expand Down
19 changes: 5 additions & 14 deletions test/.ok
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions test/.ok-sh
Original file line number Diff line number Diff line change
@@ -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
File renamed without changes.