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

[help] Differences between nio.process.run and vim.fn.jobstart #14

Closed
benlubas opened this issue Mar 30, 2024 · 2 comments
Closed

[help] Differences between nio.process.run and vim.fn.jobstart #14

benlubas opened this issue Mar 30, 2024 · 2 comments

Comments

@benlubas
Copy link

I'm running into a weird issue where two commands are behaving differently if they're run with vim.fn.jobstart or nio.process.run.

Specifically dvipng can't produce transparent images with process.run, but can with jobstart.

nio.process.run({
    cmd = "dvipng",
    args = {
        "-D",
        module.config.public.dpi,
        "-T tight",
        "-bg Transparent",
        "-fg 'cmyk 0.00 0.04 0.21 0.02'",
        "-o",
        png_result,
        ("%s.dvi"):format(document_name),
    },
})
-- vs:
nio.fn.jobstart(
    "dvipng -D "
    .. tostring(module.config.public.dpi)
    .. " -T tight -bg Transparent -fg 'cmyk 0.00 0.04 0.21 0.02' -o "
    .. png_result
    .. " "
    .. document_name
    .. ".dvi",
    { cwd = cwd }
)

image

vs:

image


Seems like job start does something special with the environment that it runs things in. Is there a way to mimic this with process.run or should I just use nio.fn.jobstart? if you have a concrete explanation for what's happening that'd be great too, I'd not been able to find anyone that has this problem with dvipng (but it's also probably a niche usecase).

@rcarriga
Copy link
Contributor

rcarriga commented Apr 5, 2024

I'm not familiar with dvipng but you're not correctly passing the arguments. They should all be separate in the array like this

nio.process.run({
  cmd = "dvipng",
  args = {
    "-D",
    module.config.public.dpi,
    "-T",
    "tight",
    "-bg",
    "Transparent",
    "-fg",
    "cmyk 0.00 0.04 0.21 0.02",
    "-o",
    png_result,
    ("%s.dvi"):format(document_name),
  },
})

It is not like a shell so you don't need to quote the arguments as you had with cmyk 0.00 0.04 0.21 0.02

@benlubas
Copy link
Author

That works, thank you. I should read the docs a little closer next time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants