Code Monkey home page Code Monkey logo

Comments (15)

santaclose avatar santaclose commented on July 21, 2024

This is how I'm doing it:
image
image

from cpp-subprocess.

arun11299 avatar arun11299 commented on July 21, 2024

@santaclose Is your last PR related to this ?
Windows support has been a 100% community effort for this repo since I haven't had a windows machine for far too long. Appreciate if you could find the issue and open a PR.

On a side note, you could try raw string

std::string command = R"(explorer /select,"C:\\Windows\")";

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

Your code snippet with he raw string didn't work either, I'll try to figure out what windows is doing with the arguments. My latest commit might not be the best solution.
image

I know that it works if szCmdLine ends up containing this exact string: explorer /select,"C:\Windows" , which also works from the command prompt.

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

So, explorer /select,"C:\Windows" works and explorer "/select,C:\Windows" doesn't work, and I don't know why.
I made a little python script just to se what the process was receiving as arguments, and for both it should be the same 🤔.
Maybe these windows apps do something different.

image

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

Seems to me the issue can be solved just by removing \" from the list of characters that need quoting:
L" \t\n\v\"" --> L" \t\n\v"
image

But there must be a reason why @xoviat added it. And also, why was the force argument always being set to true?

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

This may have been implemented incorrectly. See here for the correct implementation: https://learn.microsoft.com/en-us/archive/blogs/twistylittlepassagesallalike/everyone-quotes-command-line-arguments-the-wrong-way

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

In fact it appears that the initial implementation was correct and your PR may have introduced a bug. It also appears that you are attempting to use the shell functionality on Windows which is not currently supported.

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

thanks for the info, the only commit that was meant to be merged was the one with the call function overload, the solution for the quote issue is something temporary I pushed to my branch.

Then, from what you say, I understand I need shell functionality to run the explorer executable with the select argument?
why is this?

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

With the code before your PR was merged, you should have been able to pass the executable and arguments as an initializer list, not as one command line string. If that was not the case I can look into the issue further.

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

you mean like this?
subprocess::call("explorer", "/select,\"" + path.u8string() + "\"");
fails to compile with this error:

1>C:\Users\san\Desktop\scex\vendor\cpp-subprocess\subprocess.hpp(1377,7): error C2668: 'subprocess::detail::ArgumentDeducer::set_option': ambiguous call to overloaded function

this is at commit af23f338801ed19696da42b1f9b97f8e21dec5d6

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

for reference, this python code seems to work fine:

import subprocess
subprocess.run(r'explorer /select,"C:\Windows"')

i think this library should work when given that same string

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

see here for example: https://github.com/arun11299/cpp-subprocess/pull/91/files#diff-48ccdd15ee47b10be5729d81fb1ee3d6b0a37e113ffc53877a203300d8188b4dR43

i think this library should work when given that same string

in principle I agree. however, I think the more important functionality is to sanitize arguments when given a list. this is a large part of the reason I added this in the first place and hard to do right.

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

I'm not sure exactly what python does but it may select behavior based on whether it's passed a list or not.

from cpp-subprocess.

santaclose avatar santaclose commented on July 21, 2024

yeah probably. Also, Is there a reason why you were forcing quotes? that was pretty much bypassing most of the function logic.

from cpp-subprocess.

xoviat avatar xoviat commented on July 21, 2024

@arun11299 I will work on this more after the CI pr is merged. I think it's important to have CI running first to prevent regressions.

from cpp-subprocess.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.