Comments (4)
thanks for education, much clear for me
from luv.
Going from a string with quotes, etc to a list of arguments is typically handled by the shell, and each shell can do things differently (how to escape things, what needs to be escaped, etc), so there's no one correct way to do it AFAIK.
I believe what you'd want for those two commands would be:
{
"git",
"log",
"--pretty=%C(yellow)%h %C(cyan)%cd %C(green)%aN%C(auto)%d %Creset%s",
"--date=short",
}
and
{
"rg",
"--no-heading",
"--column",
"--",
"fzf",
}
from luv.
Hi, thanks to confirm.
I have one more question, how does the quotes and escaping characters handled by uv.spawn?
In your sample code, there's no single quote '
around the %C(yellow)%h %C(cyan)%cd %C(green)%aN%C(auto)%d %Creset%s
?
So inside uv.spawn, it will automatically add quotes for me?
from luv.
Quotes are only necessary when determining if something is a single argument or multiple arguments. Once the arguments have been split, then quotes are no longer necessary. This splitting (and therefore removal of quotes) is what the shell usually does for you.
For example, if you run something like:
myprogram "some argument"
then in myprogram
you'd get some argument
(without the quotes) as argv[1].
So, when calling uv.spawn
, you just call it with the arguments already split, so there's no need for quotes.
There is a caveat for Windows, though, since it does actually transform it back into a single string before giving it to CreateProcess
. See the options.verbatim
flag if you need to do your own quoting for Windows:
options.verbatim - If true, do not wrap any arguments in quotes, or perform any other escaping, when converting the argument list into a command line string. This option is only meaningful on Windows systems. On Unix it is silently ignored.
You'll probably need to test it on Windows to make sure it does what you expect.
Oh also, the docs are wrong about options.args
: the first value should not be the command/program name. Instead you'll want to do something like this:
uv.spawn("git", {
args = {
"log",
"--pretty=%C(yellow)%h %C(cyan)%cd %C(green)%aN%C(auto)%d %Creset%s",
"--date=short",
},
})
will update the docs about that.
from luv.
Related Issues (20)
- CI failing for LuaJIT v2.1 branch
- process creation segfault HOT 2
- Do I have to use `uv.run()` to wait async reading file with `fs_read` API? HOT 2
- Question: Is `shutdown` and `close` (use new_pipe with spawn) sync or async? HOT 1
- Question: the arrival order of uv.spawn `on_exit` and `data == nil` in `read_start` callback on Windows 10? HOT 2
- Why udp_recv_start callback call twice? HOT 2
- `tty normal` normal tests fails for me on Fedora mockbuild HOT 4
- Error loading module luv HOT 3
- Unable to send handles with uv_write2
- UBSan is detecting problems but not failing the CI
- Importance of case for signal names (and other names) HOT 1
- luv_handle_gc segfault (from neovim) HOT 8
- Flaky UDP test in CI HOT 3
- A test failure while building luv in mock for Amazon Linux 2023
- Lua 5.4.7 update HOT 4
- callbacks for signal_start and signal_start_oneshot should receive a number HOT 9
- atexit() is probably not a good way to clean up Lua VM HOT 2
- Add important 'Requires' fields to pc file
- sleep in "test threadpool with async" is non-deterministic
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luv.