• 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 thread.
View all comments View context
5 points
*

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

permalink
report
parent
reply
21 points
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.

permalink
report
parent
reply
2 points

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.

permalink
report
parent
reply
4 points

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

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
1 point

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.

permalink
report
parent
reply
-9 points

Hm, I guess I just don’t agree that CLI usablity comes before readability.

permalink
report
parent
reply
12 points

Again, it’s not just CLI, it’s an insurance against misinterpreted characters breaking programs.

permalink
report
parent
reply

Memes

!memes@lemmy.ml

Create post

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.

Community stats

  • 11K

    Monthly active users

  • 13K

    Posts

  • 288K

    Comments