-
-
Notifications
You must be signed in to change notification settings - Fork 221
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
Backslash Escaping Problems @next #316
Comments
Thanks for the question @shellscape!
I will submit a PR to improve the documentation and make the above points clearer. Also please checkout |
Perfect, thank you. |
By the way, you might get better performance by doing what |
Tacked the
|
@ehmicky when you have the time (precious as that can be) I'd like to work through resolving this one, as there doesn't seem to be any other references for this particular problem, and I'm positive it would be a good resource for someone facing the same thing in the future. |
This is an escaping problem, that's not specific to The argument passed to If you can get this working with I can try to investigate what the specific escaping of your command should be, but it does look like everything is working as intended. |
Would the following work? const diskPath = '/dev/disk1';
const {stdout} = await execa.command(`df -H ${diskPath}`);
const [line] = stdout.split('\n')
const [, size] = line.split(/ +/) This is also much faster than using |
I am doing exactly that now 😄 Still working on the escaping though, there has to be a solution to that. I'm surprised that it's not been encountered before. |
Again the escaping is not a problem, it's just about figuring out the right amount of backslashes. Also it's not specific to execa, you get the same thing with |
We're agreed on those points. |
Please note than you get several layers of escaping:
To make things more complex, escaping is completely different on Windows ( The complexity of escaping is just one of the many reasons to avoid shell interpreters unless necessary. |
I think that bit of information will be extremely helpful for folks in the future. Since it sounds like a rabbit hole, I say we leave it there. Well done, and thank you for humoring this. |
Hey folks. Using
2.0.0-alpha.0
. I've exhausted options for figuring this out (sans diving into the code). I'm trying to run a command usingexeca.command
which is throwing an error with theawk
portion of the command. Here's the raw command as used in the terminal:$ df -H /dev/disk1 | awk '/\// {printf("%s\n", $2)}'
And here's how I'm executing it in code:
I believe the error messages hold some clue. With this variation the error message reads:
If I double escape, as such:
The error message reads:
It's important that I get that regex for
awk
correct, or the command will fail to return the correct data. Is this a bug in execa and/or is there a way around this to define the command in another way that I can pass the right regex toawk
?The text was updated successfully, but these errors were encountered: