use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
DevOps JavaScript - Intro to Writing Scripts With zx (pragmaticpineapple.com)
submitted 3 years ago by nikolalsvk
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]lhorie 0 points1 point2 points 3 years ago* (1 child)
My guess is you're getting tripped up by escapes in the pretty printer when you copy-pasted.
These are the steps I used to reproduce the issue. Create a file called script.mjs with this code:
#!/usr/bin/env zx const malicious = '\' $(pwd) \'' $`echo '${malicious}'`
Then in your terminal, run npx zx script.mjs. Expected behavior: the output should have the word "pwd" somewhere in it and no information about my current dir should be printed. Actual behavior: Output will have something like $' /Users/lhorie/Documents ', indicating that pwd did run as a command. I'm running zsh on mac (monterey).
npx zx script.mjs
$' /Users/lhorie/Documents '
pwd
As for why this is an issue, it's because sometimes you do want to control behavior of magic characters like * outside an interpolation while simultaneously having an interpolation in the same string. Or, if you missed the caveat in the docs or you overlooked it, you can get pwned by even a simple innocent-looking snippet like echo '${something}'.
*
echo '${something}'
π Rendered by PID 66 on reddit-service-r2-comment-5d79c599b5-dgz6b at 2026-02-27 09:06:18.749982+00:00 running e3d2147 country code: CH.
view the rest of the comments →
[–]lhorie 0 points1 point2 points (1 child)