Bug 1095508
| Summary: | MacOS - rhq-cli.sh script command fails with 'readlink: illegal option -- f' | ||
|---|---|---|---|
| Product: | [Other] RHQ Project | Reporter: | Elias Ross <genman> |
| Component: | CLI | Assignee: | Nobody <nobody> |
| Status: | MODIFIED --- | QA Contact: | |
| Severity: | unspecified | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 4.9 | CC: | hrupp, mazz |
| Target Milestone: | --- | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Mac OS | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: | Story Points: | --- | |
| Clone Of: | Environment: | ||
| Last Closed: | Type: | Bug | |
| Regression: | --- | Mount Type: | --- |
| Documentation: | --- | CRM: | |
| Verified Versions: | Category: | --- | |
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
| Cloudforms Team: | --- | Target Upstream Version: | |
| Embargoed: | |||
| Bug Depends On: | 1153373 | ||
| Bug Blocks: | |||
|
Description
Elias Ross
2014-05-07 21:33:41 UTC
Here the proposed fix:
# ----------------------------------------------------------------------
# Change directory so the current directory is the CLI home.
# Here we assume this script is a child directory of the CLI home
# We also assume our custom environment script is located in the same
# place as this script.
# ----------------------------------------------------------------------
command -v readlink >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo >&2 'WARNING: The readlink command is not available on this platform.'
echo >&2 ' If this script was launched from a symbolic link, errors may occur.'
echo >&2 ' Consider installing readlink on this platform.'
_DOLLARZERO="$0"
else
# only certain platforms support the -e argument for readlink
if [ -n "${_LINUX}${_SOLARIS}${_CYGWIN}" ]; then
_READLINK_ARG="-e"
_DOLLARZERO=`readlink $_READLINK_ARG "$0" 2>/dev/null || echo "$0"`
elif [ -n "${_DARWIN}" ]; then
_DOLLARZERO=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd)/`basename "${BASH_SOURCE[0]}"`
else
_DOLLARZERO=`readlink "$0" 2>/dev/null || echo "$0"`
fi
fi
The strategy above is from: https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in?lq=1 merged mike t's PR:
commit 4835c7716fe6769138e1c1f3961ccd997425af5b
Merge: 04fd135 f6d158b
Author: John Mazzitelli <mazz>
Date: Tue Oct 21 16:28:44 2014 -0400
Merge pull request #144 from rhq-project/bz1095508
Bz1095508 - MacOS - rhq-cli.sh script command fails with 'readlink: illegal option -- f
put it in release 3.3 branch as well:
commit afc5a92a74aa6da7a00d5b4b475232b00b244323
Author: John Mazzitelli <mazz>
Date: Tue Oct 21 16:28:44 2014 -0400
Merge pull request #144 from rhq-project/bz1095508
Bz1095508 - MacOS - rhq-cli.sh script command fails with 'readlink: illegal option -- f(cherry pic
Signed-off-by: John Mazzitelli <mazz>
|