Skip to content

Fixing wrong usage of last's command exit code and some cleaning...#25

Open
leogtzr wants to merge 1 commit into
github-modules:masterfrom
leogtzr:master
Open

Fixing wrong usage of last's command exit code and some cleaning...#25
leogtzr wants to merge 1 commit into
github-modules:masterfrom
leogtzr:master

Conversation

@leogtzr

@leogtzr leogtzr commented Sep 13, 2017

Copy link
Copy Markdown

There was an error here:

git branch 2>/dev/null 1>&2
if [ $? -ne 0 ]; then
  echo Not a git repo!
  exit $?
fi

$? is reading the status of the last command, which is echo, so it will alwats be 0 ...

This is a good alternative:

git branch >/dev/null 2>&1
readonly RT_CODE=${?}
if ((RT_CODE != 0)); then
    echo "Not a git repo!"
    exit ${RT_CODE}
fi
Comment thread bin/ghwd
# If filename argument is present, append it
if [ "$1" ]; then
relative_path="$relative_path/$1"
if [[ ! -z "${1}" ]]; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

do all shells have -z ?

Comment thread bin/ghwd
open=$opener;
break;
fi
if command -v ${opener}; then

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

why the extra indentation here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants