Bug 1095508 - MacOS - rhq-cli.sh script command fails with 'readlink: illegal option -- f'
Summary: MacOS - rhq-cli.sh script command fails with 'readlink: illegal option -- f'
Keywords:
Status: MODIFIED
Alias: None
Product: RHQ Project
Classification: Other
Component: CLI
Version: 4.9
Hardware: Unspecified
OS: Mac OS
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Nobody
QA Contact:
URL:
Whiteboard:
Depends On: 1153373
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-05-07 21:33 UTC by Elias Ross
Modified: 2022-03-31 04:27 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed:
Embargoed:


Attachments (Terms of Use)

Description Elias Ross 2014-05-07 21:33:41 UTC
Description of problem:

rhq-cli script uses option -f not supported on Mac OS X.

http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac

Might be easiest to simply skip this behavior for this OS.

Comment 1 Mike Thompson 2014-10-21 15:43:15 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

Comment 3 Mike Thompson 2014-10-21 19:32:08 UTC
PR: https://github.com/rhq-project/rhq/pull/144

Comment 4 John Mazzitelli 2014-10-21 20:35:58 UTC
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>


Note You need to log in before you can comment on or make changes to this bug.