Startup scripts broken on Linux due to readlink command #8

Merged
sql-workbench merged 1 commits from aporter/sql-workbench:master into master 9 months ago
aporter commented 9 months ago

The GNU/Linux version of readlink with no options does not write the canonicalize path to
stdout, whereas the MacOS version does not appear to accept any options. Added a function to decide how readlink should be called based on OS type.

Unfortunately I do not have access to a system with MacOS to verify this still works there. But since it defaults to the readlink command format that was added in an earlier commit just for MacOS, it probably should. If it does not, let me know what the output is and I will update the PR.

The GNU/Linux version of readlink with no options does not write the canonicalize path to stdout, whereas the MacOS version does not appear to accept any options. Added a function to decide how readlink should be called based on OS type. Unfortunately I do not have access to a system with MacOS to verify this still works there. But since it defaults to the readlink command format that was added in an earlier commit just for MacOS, it probably should. If it does not, let me know what the output is and I will update the PR.
aporter added 1 commit 9 months ago
fe89e70f39 Startup scripts broken on Linux due to readlink command

Interesting, the readlink was added in PR #2 by a Mac user ;)

The current script works for me on CentOS 7

Interesting, the readlink was added in [PR #2](https://codeberg.org/sql-workbench/workbench/pulls/2) by a Mac user ;) The current script works for me on CentOS 7
Poster

Hmm, how true. I just saw the "-e" option removed in commit e9247146, and assumed it was because that was not supported on MacOS. And doing some research seemed to confirm that, but without access to a Mac I could not be sure. Maybe @unguiculus would be kind enough to help clarify?

Hmm, how true. I just saw the "-e" option removed in commit e9247146, and assumed it was because that was not supported on MacOS. And doing some research seemed to confirm that, but without access to a Mac I could not be sure. Maybe @unguiculus would be kind enough to help clarify?
Poster

So maybe my issue is more specific to Ubuntu/Debian. There are so many variants of the readlink command it makes it difficult to solve in a portable way. The realpath command was made in part to solve this, but I am not sure if we can depend on that always being available.

So maybe my issue is more specific to Ubuntu/Debian. There are so many variants of the readlink command it makes it difficult to solve in a portable way. The realpath command was made in part to solve this, but I am not sure if we can depend on that always being available.

Hmm. I have an Ubuntu 16.04 LTS where the current script (without -e) works as well.

But your script works also, so I don't see any reason not to use it (unless it breaks on MacOS)

Hmm. I have an Ubuntu 16.04 LTS where the current script (without `-e`) works as well. But your script works also, so I don't see any reason not to use it (unless it breaks on MacOS)
Poster

Do you have the scripts soft-linked? I just tried it running the readlink command in RHEL 5, CentOS 7, and Ubuntu 18.04 without any options. If the path is not a link, on all three it just returned an error code with no output. Output was only generated when the given path was a soft-link.

Do you have the scripts soft-linked? I just tried it running the readlink command in RHEL 5, CentOS 7, and Ubuntu 18.04 without any options. If the path is not a link, on all three it just returned an error code with no output. Output was only generated when the given path was a soft-link.

Ah! That makes a difference.

If I cd into a directory which is a symlink, either version works.

But if the (symlink'ed) directory is not the current one, and I run the script by specifying the full path (e.g. ~/sqlworkbench/sqlwbconsole.sh) then the current script breaks. Your solution works in both cases.

Ah! That makes a difference. If I `cd` into a directory which is a symlink, either version works. But if the (symlink'ed) directory is not the current one, and I run the script by specifying the full path (e.g. `~/sqlworkbench/sqlwbconsole.sh`) then the current script breaks. Your solution works in both cases.
sql-workbench merged commit 74f202a0e3 into master 9 months ago
The pull request has been merged as 74f202a0e3.
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This pull request currently doesn't have any dependencies.

Loading…
There is no content yet.