Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass argument wrapped in single quotes to script run by cli-test-utils #2204

Open
t1m0thyj opened this issue Jul 23, 2024 · 3 comments
Labels
bug Something isn't working priority-low Legit issue but cosmetic or nice-to-have severity-low Bug that makes the usage of the Zowe less convenient but doesn't impact key use cases

Comments

@t1m0thyj
Copy link
Member

t1m0thyj commented Jul 23, 2024

Describe the bug

When invoking the runCliScript method from the cli-test-utils SDK to run a Bash script, I am unable to pass arguments that must be wrapped in single quotes because the quotes get mangled.

For example, when trying to pass a fully qualified dsname IBMUSER.OPSREXX.PS, it is common to wrap it in single quotes (e.g., 'IBMUSER.OPSREXX.PS') so that z/OS doesn't prepend the user HLQ IBMUSER.

Note: This issue exists only on Windows.

Expected and actual results

For a minimal reproduction of the issue, I've used child_process.spawnSync which is the underlying function called by runCliScript.

test-quotes.sh

#!/bin/bash
set -e
dsname=$1
echo "dsname: $dsname"

test-quotes.js

const childProcess = require("child_process");
const dsname = `'IBMUSER.OPSREXX.PS'`;
childProcess.spawnSync("sh", ["test-quotes.sh", dsname], { stdio: "inherit" });

Expected Behavior: The dsname should be printed verbatim with single quotes intact.

Actual Behavior: The script outputs the dsname with quotes stripped off. Is this a bug in Node.js?

The following workaround exists and could be documented, but is not very intuitive:
const dsname = `'\\'IBMUSER.OPSREXX.PS\\''`;

Describe your environment

  • Zowe CLI version installed (run command zowe --version): 8.0.0-next.202407181904
  • Installed plug-ins and their version numbers (run command zowe plugins list --short): N/A
  • Node.js and NPM versions installed (run node --version, npm --version): Node 18.20.4, npm 10.7.0
  • Environment variables in use: N/A
  • Operating system and version: Win10 build 19045
  • Shell/terminal (bash, cmd, powershell, etc...): Git Bash
  • Daemon mode enabled or disabled: Enabled

Additional context

CLI arg parsing may have changed between Zowe V2 and V3, since we updated to a new major version of yargs-parser - see yargs/yargs-parser#407

@t1m0thyj t1m0thyj added bug Something isn't working new The issue wasn't triaged yet labels Jul 23, 2024
Copy link

Thank you for creating a bug report.
We will investigate the bug and evaluate its impact on the product.
If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.

@JTonda JTonda removed the new The issue wasn't triaged yet label Jul 24, 2024
@JTonda
Copy link

JTonda commented Jul 24, 2024

Note:

  • Document how to properly escape single quotes in certain situations
  • Location: Docs w/ a link to that file from this issue

This should be resolved in V3

@JTonda JTonda added priority-low Legit issue but cosmetic or nice-to-have severity-low Bug that makes the usage of the Zowe less convenient but doesn't impact key use cases labels Jul 24, 2024
@adam-wolfe
Copy link
Contributor

adam-wolfe commented Aug 12, 2024

Moved back to New Issues to discuss if there is anything we can/should do to resolve this behavior in v2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-low Legit issue but cosmetic or nice-to-have severity-low Bug that makes the usage of the Zowe less convenient but doesn't impact key use cases
Projects
Status: Low Priority
Development

No branches or pull requests

3 participants