-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
After upgrading to 7.1 No quote function is defined: https://ï.at/no-quote-func #524
Comments
@geoffreysamper I wonder what's the difference between your code: await $`echo ${process.env.HOSTNAME}` and the one in readme (https://github.com/google/zx#passing-env-variables): await $`echo $FOO` The effect is probably the same, but I'm just wondering because I haven't tested it. What is the effect when you use it like below? await $`echo $HOSTNAME` |
Alpine does not have bash. Only sh (csh probably?) Zx doesn't have a quote function for csh, as zx uses $ escape bash feature. You can fix it by adding bash:
|
when adding bash to it alpine image it works |
When running using the bash variable instead of the process it works
|
Didn't get it. |
when running await $ So changing the statement from
to
|
Is there a reason why bash is a requirement for zx. The puprose of the ZX is to use javascript and bash statement together. Isn't the quote function the same for most linux shells? |
Unfortunately no. Bash has this nice quote C strings: https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html |
you saved me. This definitely needs to be specified in README |
I have a similar problem. I currently try to write a Raycast script with
doesn't work as it just executes the |
Probably the safest option is still to install bash to avoid issues when quoting is actually needed, but i thought i'll share my findings as well. I managed to get it working on alpine with following patch for ash shell: diff --git a/node_modules/zx/build/core.js b/node_modules/zx/build/core.js
index 6de412b..3354f76 100644
--- a/node_modules/zx/build/core.js
+++ b/node_modules/zx/build/core.js
@@ -49,6 +49,17 @@ catch (err) {
if (process.platform == 'win32') {
defaults.shell = which.sync('powershell.exe');
defaults.quote = quotePowerShell;
+ } else {
+ if (process.platform == 'linux') {
+ try {
+ defaults.shell = which.sync('ash');
+ defaults.prefix = 'set -euo pipefail;';
+ defaults.quote = quote;
+ }
+ catch (err) {
+ // ignore - unknown linux shell
+ }
+ }
}
}
function getStore() { but i haven't tested it it also works if quoting would actually be needed (my use-case doesn't actually need quoting). To make it backwards compatible with v7.0.8, better solution would be to modify default quote implementation, so it wouldn't fail if quoting is needed. @antonmedv, what do you think? |
Let's stick with the bash. |
Supporting |
sh in alpine uses variant of https://linux.die.net/man/1/ash which does not support bash But you can install bash in the docker container in a separate layer. It should be straightforward. |
Expected Behavior
when running a command below expect that the command it echo the hostname.
Actual Behavior
If i go to the prev version of zx 7.0.8 everything works
Steps to Reproduce the Problem
docker run geoffreysamper/zx-alpine-issue
the git repo for the sample is https://github.com/geoffreysamper/zx-issue-no-quoteSpecifications
The text was updated successfully, but these errors were encountered: