Bug 959603
| Summary: | CLI changes working directory; making it harder to run scripts | |||
|---|---|---|---|---|
| Product: | [Other] RHQ Project | Reporter: | Elias Ross <genman> | |
| Component: | CLI | Assignee: | Lukas Krejci <lkrejci> | |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Mike Foley <mfoley> | |
| Severity: | unspecified | Docs Contact: | ||
| Priority: | unspecified | |||
| Version: | 4.5 | CC: | hrupp | |
| Target Milestone: | --- | |||
| Target Release: | RHQ 4.10 | |||
| Hardware: | Unspecified | |||
| OS: | Unspecified | |||
| Whiteboard: | ||||
| Fixed In Version: | Doc Type: | Bug Fix | ||
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1042495 (view as bug list) | Environment: | ||
| Last Closed: | 2014-04-23 12:29:55 UTC | 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: | ||||
| Bug Blocks: | 1042495 | |||
Lukas, can you please have a look? I fear that change is less than minor due to possible behavior change in downstream JON I agree that this behavior is somewhat confusing. That said, we've been shipping the scripts like that since the very beginning and people probably have worked around that behavior. I am actually not sure why that behavior is in place, it seems to just have been copied from the agent start up script (where I am not sure about the behavior either). But because of the backwards compatibility reasons I think we should not change this behavior by default. What I think we MIGHT do though is the following: 1) Make the changing of the directory optional based on (yet another) env var: RHQ_CLI_CHANGE_DIR_ON_START 2) Put this env variable inside rhq-cli-env.sh (uncommented) 3) Parametrize that file during the maven build 4) In RHQ, let it default to false 5) JBoss ON build can customize it to true That way we can make the switch to the new behavior immediately in RHQ but provide a backwards-compatible behavior for people using JON as well as a way of swapping that behavior either by users themselves or at some future release by us. commit f35bbe1a20a775c8273b551a924261e254dd199d
Author: Lukas Krejci <lkrejci>
Date: Thu Dec 12 23:10:14 2013 +0100
[BZ 959603] - Don't change CWD on CLI startup.
Since the very beginning of CLI, RHQ always changed the CWD to
$RHQ_CLI_HOME when starting up, which is rather strange and
non-standard.
To keep the backwards compatibility, the behavior can be toggled on
or off.
The default behavior can be changed in the build by setting the
rhq.cli.change-dir-on-start-default
property. In RHQ, this defaults to "false", causing RHQ to NOT change
directories when starting up the CLI anymore.
Further, the behavior can be toggled by the user by setting the
RHQ_CLI_CHANGE_DIR_ON_START environment variable to "true" (or any
other value but "false" actually) or "false" explicitly.
Additionally, a new environment variable called "RHQ_CLI_MODULES_DIR"
was added. This was necessary to not break the loading of the
provided CommonJS modules available in the
$RHQ_CLI_HOME/samples/modules directory if the CLI was started from
another directory.
By adding the new RHQ_CLI_MODULES_DIR, which is initialized to the
correct value if not provided externally, we correctly load the
sample modules with the additional benefit of easier change of the
modules location for the user (previously this was only possible
through
RHQ_CLI_ADDITIONAL_JAVA_OPTS="-Drhq.scripting.modules.root-dir=..."
, while now one only needs RHQ_CLI_MODULES_DIR=...).
Bulk closing of 4.10 issues. If an issue is not solved for you, please open a new BZ (or clone the existing one) with a version designator of 4.10. |
There is no reason for the CLI to change the working directory. This means execution of scripts outside of the RHQ_CLI_HOME directory requires a user to put in the full path of the script, even though it is in the working directory. The solution is to simply remove the 'cd' commands like so: --- ../../rhq-remoting-cli-4.4.0/bin/rhq-cli.sh 2012-08-09 12:43:17.000000000 -0700 +++ rhq-cli.sh 2013-05-03 16:42:18.000000000 -0700 @@ -50,15 +50,13 @@ fi if [ -z "$RHQ_CLI_HOME" ]; then - cd "${RHQ_CLI_BIN_DIR_PATH}/.." -else - cd "${RHQ_CLI_HOME}" || { - echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}" - exit 1 - } + RHQ_CLI_HOME="${RHQ_CLI_BIN_DIR_PATH}/.." fi -RHQ_CLI_HOME=`pwd` +test -d "${RHQ_CLI_HOME}" || { + echo "Cannot go to the RHQ_CLI_HOME directory: ${RHQ_CLI_HOME}" + exit 1 + } debug_msg "RHQ_CLI_HOME: $RHQ_CLI_HOME"