On 28.08.19 г. 16:06 ч., Steven Rostedt wrote:
On Tue, 27 Aug 2019 22:10:18 -0700 stephen@xxxxxxxxxx wrote:It strikes me that this explicitly supports only a single set of quotes. This sort of behavior would be pretty surprising for people expecting shell quote support, and for people expecting just splitting on spaces. I looked and couldn't really find any Qt utility for properly parsing shell quoting (similar to python's shlex module). I totally get that it's a lot of work to implement a correct shell quoting parser. Maybe a compromise would be to add a checkbox to the capture dialog, which tells kernel-shark to pass the entire textbox contents, unmodified, to the shell implementation on the system. So, my example of: python -c 'print("hello world")' Would get put into the third argument of the command: /bin/sh -c INSERT_TEXTBOX_CONTENTS_HERE Then you could rely on /bin/sh doing the parsing for you. The downside is that it adds a whole new process. But you can't always get everything in life, right?I need to look at this a bit deeper. I've written lots of cases where I had to capture single and double quotes and turn them into a single command. This is definitely needed here.
Can you send me few of the of most trickier examples that comes to your mind, so that I can use them to test the parsing?
Thanks! Yordan
I'm very reluctant to just use a simple /bin/sh, as this is being run as root. Grant you, it is open to do anything, but I rather not just make it into a root shell. Although we still allow you to run any command. But once you add a full shell with the "sh -c" you now need to deal with environment variables and such, which can cause more unexpected side effects. Basically, we want to be able to add single and double quotes, as well as backslashes: my -c 'command\'s here' and '\\' this "too" Thanks for the feedback. -- Steve