OK, I read through the xargs documentation, pretty cool!

@vaporeon_ oh wow, posix xargs doesn’t suppurrt using null characters as a sepurrator

@aescling What would be the use-case for null characters as separators? Processing files that have a newline in the name?

@aescling Personally my opinion is that if you put a newline inside a filename, you deserve whatever troubles this causes you... It's just a wrong thing to do, even if it's technically allowed...

But I understand that not everyone may agree with that.

@vaporeon_ @aescling This has happened before by accident as a result of trying to operate on text files/scripts that were saved in windows notepad.

@aescling @vaporeon_ One thing we did was a script that would take every line in a text file and make an empty file named for it
Say the document says:
Super Mario Bros
Luigi's Mansion
Sonic the Hedgehog 2

After the last character of every line it would have a newline characters because bash assumes Linux line endings instead of windows

So you get a file named Super Mario Bros[CR].

@onfy @aescling Hmmm.... cat your-file-list | tr -d '\r' | xargs touch?
(Without testing, give me a few seconds to test this)

@onfy @aescling Never mind, this doesn't work because apparently xargs treats quotation marks (like the one in Luigi's Mansion) as special characters... So instead, I have to do:

cat games-list | tr -d '\r' | tr '\n' '\0' | xargs -0 touch

@aescling @onfy Good news! I went and checked POSIX 2024 instead of POSIX 2004, and that actually specifies the -0 option, too: pubs.opengroup.org/onlinepubs/

@aescling @onfy But it really got added only in the latest verson of POSIX, I tried versions from 2008, 2013, 2016, and 2018, and they don't have it there yet

Sign in to participate in the conversation
📟🐱 GlitchCat

A small, community‐oriented Mastodon‐compatible Fediverse (GlitchSoc) instance managed as a joint venture between the cat and KIBI families.