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

Avoid creating a conflicting alias #89

Merged
merged 3 commits into from
Oct 30, 2020

Conversation

PierreRustOrange
Copy link
Contributor

@PierreRustOrange PierreRustOrange commented Apr 9, 2020

This fixes issue #88 .

Please note that while I tested it locally, I did not perform an end-to-end test, as the get.sh script downloads directly from github.

@derek
Copy link

derek bot commented Apr 9, 2020

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide.
Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.

Do NOT create the alias if there is already a binary with the same name
in the path.

Signed-off-by: PierreRustOrange <pierre.rust@orange.com>
@alexellis
Copy link
Owner

Thanks for the PR. Just need to check that whereis exists on Git Bash, MacOS and Linux (bash)

@alexellis
Copy link
Owner

Thanks to @mehyedes, it seems that whereis is not supported in Git Bash, so perhaps where could substitute? https://stackoverflow.com/questions/54485435/git-bash-whereis-command-not-found

@mehyedes
Copy link

mehyedes commented Apr 14, 2020

Using which would be better here IMHO, as it is available also on Git Bash.
Besides, we're just trying to find out if the alias exists, so the format of the output is not that important to us.
We can use the exit code of the which command, to see if it ran successfully by checking the value of $?. If it returns 1, it means the symlink does not exist in the path:

$ ln -nfs /usr/bin/docker /usr/bin/docker-alias
$ which docker-alias
/bin/docker-alias
$ echo $?
0

That should also work on Git Bash

@derek
Copy link

derek bot commented Apr 14, 2020

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide.
Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.

@derek derek bot added the no-dco label Apr 14, 2020
which is available on git bash and is enough, as we simply need to check
if the alias already exist, we don't really care where it is.

Signed-off-by: PierreRustOrange <pierre.rust@orange.com>
@PierreRustOrange
Copy link
Contributor Author

OK, you're right, which is enough and it makes the code simpler. I've pushed the corresponding modification.

@derek derek bot removed the no-dco label Apr 14, 2020
get.sh Outdated
ln -s $BINLOCATION/$REPO $BINLOCATION/$ALIAS_NAME
echo "Creating alias '$ALIAS_NAME' for '$REPO'."
if [ $(which $ALIAS_NAME) ]; then
echo "There is already a command '$ALIAS_NAME' in the path, do NOT create alias"

This comment was marked as resolved.

Signed-off-by: PierreRustOrange <pierre.rust@orange.com>
@mehyedes
Copy link

Thanks ! Looks fine now 👍

@Waterdrips
Copy link
Contributor

LGTM. Tested on Linux.

Copy link
Owner

@alexellis alexellis left a comment

Choose a reason for hiding this comment

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

Approved

@alexellis alexellis merged commit 3ae1425 into alexellis:master Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants