629
submitted 11 months ago by qaz@lemmy.world to c/memes@lemmy.ml
  • ISO 8601 is paywalled
  • RFC allows a space instead of a T (e.g. 2020-12-09 16:09:...) which is nicer to read.
you are viewing a single comment's thread
view the rest of the comments
[-] rtxn@lemmy.world 74 points 11 months ago* (last edited 11 months ago)

You've just become the nemesis of the entire unix-like userbase for praising the space.

[-] meekah@lemmy.world 21 points 11 months ago* (last edited 11 months ago)

What's the issue with the space?

[-] rtxn@lemmy.world 45 points 11 months ago

On the command line, space is what separates each argument. If a path contains a space, you either have to quote the entire path, or use an escape character (e.g. the \ character in most shells, the backtick in Powershell because Microsoft is weird, or the character's hexadecimal value), otherwise the path will be passed to the command as separate arguments. For example, cat hello world.txt would try to print the files hello and world.txt.

It is a good practice to minimize the character set used by filenames, and best to only use English alphanumeric characters and certain symbols like -, _, and .. Non-printable characters (like the lower half of ASCII), weird diacritics (like ő or ű), ligatures, or any characters that could be misinterpreted by a program should be avoided.

This is why byte-safe encodings, like base64 or percent-encoding, are important. Transmitting data directly as text runs the risk of mangling the characters because some program misinterpreted them.

[-] meekah@lemmy.world 4 points 11 months ago* (last edited 11 months ago)

but what does the command line matter for dates? sure every once in a while you'll have to pass a date as an argument on the command line but I think usually that kind of data is handled by APIs without human intervention, so once these are set up properly, I don't see the problem

[-] rtxn@lemmy.world 21 points 11 months ago
rsync -a "somedir" "somedir_backup_$(date)"

If the date command returns an RFC-3339-formatted string, the filename will contain a space. If, for example, you want to iterate over the files using for d in $(find...) and forget to set $IFS properly, it can cause issues.

[-] lolcatnip@reddthat.com 2 points 11 months ago

But $(date) does return a string with spaces, at least on every system I've ever used. And what's so bad about the possibility of spaces in filenames? They're slightly inconvenient in a command line, but I haven't used a commuter this century that didn't support spaces in filenames.

[-] rtxn@lemmy.world 4 points 11 months ago

Bro, literally re-read the comment you replied to. It has an example of what might happen.

[-] lolcatnip@reddthat.com 1 points 11 months ago* (last edited 11 months ago)

Ok, I just reread it. I don't see what you think I'm missing. You mean an improperly written find command misbehaving? The fact that a different date format could prevent a bug from manifesting doesn't seem like much of an argument.

[-] black0ut@pawb.social 2 points 11 months ago

Spaces can exist in filenames. The only problem is that they have to be escaped. As the comment that you reread explained, cat hello world.txt would print the files hello and world.txt. If you wanted to print the file "hello world.txt" you'd either need to quote it (cat "hello world.txt") or escape the space (cat hello\ world.txt)

[-] lolcatnip@reddthat.com 2 points 11 months ago

Oh, the horror!

[-] calcopiritus@lemmy.world 1 points 11 months ago

Both arguments are surrounded by ", which should be space-safe.

At least in the shells I use, putting " makes spaces inside paths a non-issue.

[-] rtxn@lemmy.world 1 points 11 months ago

For the rsync command, yes. But this:

for d in $(find . -type d); do
    echo "$d"
done

will process the space-separated parts of each path as separate items. I had to work around this issue just two days ago, it's an obscure thing that not everyone will keep in mind.

[-] Knusper@feddit.de 4 points 11 months ago

I'm not exactly fond of the space either, but man, the T is noisy. They could've gone with an underscore or something, so it actually looks like two different sections.

this post was submitted on 12 Dec 2023
629 points (95.1% liked)

Memes

45755 readers
1021 users here now

Rules:

  1. Be civil and nice.
  2. Try not to excessively repost, as a rule of thumb, wait at least 2 months to do it if you have to.

founded 5 years ago
MODERATORS