Skip to content

[BUG] 'rtk ls' parsing issue #948

@fredperso

Description

@fredperso

Related to #822

rtk ls misparses ls -la output on systems where owner/group columns contain spaces, causing
incorrect filenames and 0B sizes

Description

rtk ls currently parses the plain text output of ls -la by splitting each line on whitespace and
assuming fixed column positions.

That assumption breaks on systems where the owner or group field contains spaces. In that case,
the columns shift, so RTK reads the wrong token as the file size and also reconstructs the
filename incorrectly.

As a result:

  • some files are shown with a size of 0B even when they are not empty
  • some entry names include trailing date/time fragments such as 31 16:18
  • directory/file names can be corrupted in the compact output

Current implementation

In dev/projets/rtk/src/cmds/system/ls.rs:162, the code does:

  • split each ls -la line with split_whitespace()
  • assume parts[4] is the size
  • assume parts[8..] is the filename

This is fragile because ls output is not a stable machine-readable format.

Relevant lines:

  • dev/projets/rtk/src/cmds/system/ls.rs:162
  • dev/projets/rtk/src/cmds/system/ls.rs:167
  • dev/projets/rtk/src/cmds/system/ls.rs:185

Environment where reproduced

On this machine, ls -la shows a group name with spaces, for example:

-rw-r--r-- 1 fjeanne utilisa. du domaine 0 Mar 31 16:18 empty.txt

RTK output for the same directory becomes:

31 16:18 empty.txt 0B

This demonstrates that the parser is consuming part of the date/time as part of the filename and
defaulting the size to 0.

Steps to reproduce

  1. Use a system where the owner or group name contains spaces in ls -la output.
  2. Create a test directory with at least one file.
  3. Run ls -la .
  4. Run rtk ls .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeffort-smallQuelques heures, 1 fichierfilter-qualityFilter produces incorrect/truncated signalgood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions