Skip to content

adds switch for macos systems to use greadlink instead#1885

Closed
mommel wants to merge 4 commits intodocker-mailserver:masterfrom
mommel:fixes-readlink-issue-for-darwin
Closed

adds switch for macos systems to use greadlink instead#1885
mommel wants to merge 4 commits intodocker-mailserver:masterfrom
mommel:fixes-readlink-issue-for-darwin

Conversation

@mommel
Copy link
Copy Markdown

@mommel mommel commented Apr 5, 2021

Issue on macos is readlink does not support -f greadlink instead does

Description

readlink on macos does not support -f

Fixes # (issue)
#1884

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code

@casperklein casperklein linked an issue Apr 5, 2021 that may be closed by this pull request
@casperklein casperklein added area/enhancement kind/improvement Improve an existing feature, configuration file or the documentation priority/medium labels Apr 5, 2021
@casperklein
Copy link
Copy Markdown
Member

Thank you for the contribution 👍 However there were two bugs:

  1. _use_readlink was never called
  2. The if condition did not work

I fixed both issues. Please review and test my changes on MacOS.

@casperklein casperklein requested a review from a team April 6, 2021 00:17
@georglauterbach
Copy link
Copy Markdown
Member

This PR fixes a problem which should in theory not even exist. Looking at the code, the failure of calling readlink -f should have been catched by the if... else... construct. @casperklein what's your take?

Comment thread setup.sh
Comment thread setup.sh
Comment thread setup.sh
if uname -a | grep -q Darwin
then
CDIR="$(dirname "$(readlink -f "${0}")")"
SCRIPT_PATH="$(greadlink -f "${0}")"
Copy link
Copy Markdown
Member

@georglauterbach georglauterbach Apr 6, 2021

Choose a reason for hiding this comment

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

We should not use greadlink. We do not officially support macOS. The script should work in a way which

  1. Checks if dirname "$(readlink -f "${0}")" works, if not, go on
  2. Checks if realpath -e -L "${0}" works, if not, use the value provided on initialization, which is
  3. The value of $(pwd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree. That was one of the reasons, I haven't approved this PR yet. I don't have a Mac to test with. That would imply, that neither pwd nor realpath is available in @mommel's environment, which sounds strange.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pwd does exist on Big Sur, realpath does not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@fbartels Thanks for pointing this out! But as long as one of the three commands work, this should not be a problem in the end, i.e. I still have no clue as to why this should not work :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about getting rid of the whole _get_current_directory function? 😄

CDIR=${0%/*} should all we need. Pure Bash and no dependencies to other binarys.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What about getting rid of the whole _get_current_directory function? smile

CDIR=${0%/*} should all we need. Pure Bash and no dependencies to other binarys.

Quite nice, but only under the condition that working with relative paths is okay. I do not see an problems at the moment, but I'm not 100% confident either.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I've considered this. In the current code, there is no need for an absolute path.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, I've considered this. In the current code, there is no need for an absolute path.

Although we're "losing" the capability to resolve softlinks, this should not be an issue altogether. I will close this PR. Can you provide a new one which implements this behavior?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Unfortunately, an absolute path is required for docker -v command 😕

@georglauterbach
Copy link
Copy Markdown
Member

This would need rebasing. But I guess opening a new PR (if still needed) is easier.

mommel and others added 4 commits April 10, 2021 08:32
adds switch for macos systems to use greadlink instead

Issue on macos is readlink does not support -f greadlink instead does
@mommel mommel closed this Apr 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement Improve an existing feature, configuration file or the documentation priority/medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] readlink does not support param -f on macos systems

4 participants