Skip to content

The TableParser is broken #6

@ryanbooker

Description

@ryanbooker

It assumes ' ' is always a separator. For ps output, the CMD can be full of spaces.

e.g.

> ps | fsh -p table id

PID       TTY           TIME       CMD       -p       table       id      
38964     ttys000       0:02.21    -zsh     
55462     ttys000       0:00.00    fsh      

Note the -p table id floating up to the right and no longer properly in the CMD field. The lines in the table are broken out as follows:

["PID","TTY","TIME","CMD"]
[["38964" ,"ttys000" ,"0:02.21" ,"-zsh"] ,["55462" ,"ttys000" ,"0:00.00" ,"fsh" ,"-p" ,"table" ,"id"]]

Where it needs to be:

["PID","TTY","TIME","CMD"]
[["38964" ,"ttys000" ,"0:02.21" ,"-zsh"] ,["55462" ,"ttys000" ,"0:00.00" ,"fsh -p table id"]]

It's not clear to me what a good solution to this is. Are there other commands that output tables? Do they all have an "everything else" style last column similar to CMD? i.e. could we assume that the last column should collect up all remaining words (using the column headers count to decide when we're in the last column or something like that)? Should there be a ps specific parser instead?

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions