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

Should extract duplicate code in scripts #73

Open
duchainer opened this issue May 29, 2020 · 1 comment
Open

Should extract duplicate code in scripts #73

duchainer opened this issue May 29, 2020 · 1 comment
Assignees

Comments

@duchainer
Copy link
Member

See sara_install/script/

This code is the exact same in more than 4 files:

if [[ $SHELL_EXTENSION == "bash" ]]
then
    WSDIR=$(readlink -f $(dirname $(dirname "${BASH_SOURCE[0]}")))
elif [[ $SHELL_EXTENSION == "zsh" ]]
then
    WSDIR="$(dirname $(readlink -f ${0%/*}))";
else
    echo "This shell is not supported. Please use bash or zsh."
    exit -1 # Not permitted
fi

Later modification will become difficult to do correctly if it stays

Maybe source a separate file containing the identical code or use an external function.

@duchainer
Copy link
Member Author

Also check this duplicated code :

if [[ $SARA_FORCE_SSH == "true" ]]
then
	echo "SARA_FORCE_SSH is true. Forcing ssh mode."
	bash -c "source script/_switch_https_ssh.sh``` -s or -h ```"
fi

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

No branches or pull requests

2 participants