natsort icon indicating copy to clipboard operation
natsort copied to clipboard

Equivalent of `sort --zero-terminated` to sort null-terminated lines from stdin

Open baldassarreFe opened this issue 9 months ago • 1 comments

Describe the feature or enhancement

Parse null-terminated strings when sorting lines from stdin.

Provide a concrete example of how the feature or enhancement will improve natsort

When working with filenames that contain spaces, a common pattern is

find . -name 'some pattern' -print0 | sort --zero-terminated

Is it possible to implement the same for natsort? I.e. a bool command-line argument that, if set, causes natsort to split stdin on null characters and sort the resulting "lines".

Would you be willing to submit a Pull Request for this feature?

I would find this feature useful. If there is interest, and if someone can point me at the right files, I can submit a PR for it.

baldassarreFe avatar Mar 04 '25 17:03 baldassarreFe

This should be possible. I imagine it would just be modifying the code around line 181 in __main__.py to split on the "\0" character if that flag is provided.

SethMMorton avatar Mar 05 '25 06:03 SethMMorton

Closed in #180

SethMMorton avatar Aug 01 '25 15:08 SethMMorton