Skip to content
Open
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
23 changes: 7 additions & 16 deletions guider/guider
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you restrict the shell to bash?
It will cause error on systems without bash.
There are also various shells such as dochsh, dash, rbash, rsh...


# Guider Launcher
#
# Copyright (c) 2016-2021 Peace Lee <iipeace5@gmail.com>
Expand All @@ -7,23 +9,12 @@
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.

# check python #
if [ ! $PYTHON ]
# check valid Python in order: user-specified, python, python3 and 2 #
PYTHON=`which $PYTHON || which python || which python3 || which python2`

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks nice! :)

if [ z`$PYTHON -V 2>/dev/null | cut -d' ' -f1` != "zPython" ]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using regular expressions instead of external commands like cut?

then
PYTHON=$(which python)
if [ ! $PYTHON ]
then
PYTHON=$(which python3)
if [ ! $PYTHON ]
then
PYTHON=$(which python2)
if [ ! $PYTHON ]
then
echo "[Error] fail to find python"
exit
fi
fi
fi
echo "[Error] fail to find python"
exit
fi

# export CMDLINE for Guider #
Expand Down