-
Notifications
You must be signed in to change notification settings - Fork 41
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
wrong split command and arguments if path contains spaces #11
Comments
this actually is an already known issue that I don't have a good solution for now. This could be solved easily if only by your case, but the key point is the way to distinguish a normal space and a space that within a path. Actually table-parser already handled similar situation in Windows like:
Table-Parser will not split if the space is within double-quotes, but the situation you pointed out is quite different to identify. I have checked out another ps node module, named ps-list by @sindresorhus and turned out this module doesn't split command and arguments at all so that it doesn't need to worry about this problem. Any idea is welcomed, and I will keep on looking for solutions. |
Since I use ps-node only for non regression tests, an obvious solution is to rename "Google Chrome" to "GoogleChrome" on my mac (or use ps-list, or hack my own really simple dedicated code). Having thought a bit about this problem, I think that you can't get a general solution, since sometimes arguments are indistinguishable from command name without knowledge of the OS. See this example of 'ps -A' output on osX: What does this mean? A program with a space in its name ("lsd runAsRoot") or an argument to the lsd program without single or double hyphen? It's the latter, but how your program could know this? The output of ps command is not a table with space separated fields, so you can't use your table-parser module to analyse it. |
Hi @herve-g not sure if you are still watching this issue, but just want to let you know that @moos got a solution for it, you can take a look #56 (comment) |
Thank you for the info. I managed to do otherwise.
Le 10 mai 2017 à 08:17, Neekey <[email protected]> a écrit :
Hi @herve-g not sure if you are still watching this issue, but just want to let you know that @moos got a solution for it, you can take a look #56 (comment)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
…unded by quotations This is done by calling /proc/<PID>/cmdline where the arguments are separated by NUL characters rather than spaces. This can then be split up and parsed.
A issue reported:
I’m porting my program to osX, and found a bug in ps-node.
On osX, commands path may contain spaces. For instance I’m trying to find ocurrences of Google Chrome, and here is an example of ‘ps -A’ command output:
See the space between ‘Google' and ‘Chrome’?
You obviously use the space to separate the command from its arguments, which is wrong on osX. The resulting object of your parsing contains (for instance):
I suppose that you could replace the line in table-parser/lib/index.js
by something like:
to eliminate the spaces between slashes inside fields. This may benefit to arguments too, since they can contain a path with a space.
I didn’t check the bug on previous versions of ps-node.
The text was updated successfully, but these errors were encountered: