• ISO 8601 is paywalled
  • RFC allows a space instead of a T (e.g. 2020-12-09 16:09:…) which is nicer to read.
  • rtxn@lemmy.world
    link
    fedilink
    English
    arrow-up
    29
    arrow-down
    1
    ·
    edit-2
    1 year ago

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

      • rtxn@lemmy.world
        link
        fedilink
        English
        arrow-up
        13
        ·
        1 year 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.

        • silly goose meekah@lemmy.world
          link
          fedilink
          arrow-up
          3
          arrow-down
          1
          ·
          edit-2
          1 year 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
            link
            fedilink
            English
            arrow-up
            7
            ·
            1 year 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.

            • calcopiritus@lemmy.world
              link
              fedilink
              arrow-up
              1
              ·
              1 year 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
                link
                fedilink
                English
                arrow-up
                1
                ·
                1 year 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.

              • rtxn@lemmy.world
                link
                fedilink
                English
                arrow-up
                5
                ·
                1 year ago

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

                  • rtxn@lemmy.world
                    link
                    fedilink
                    English
                    arrow-up
                    1
                    ·
                    1 year ago

                    Yeah? I once spent an entire week debugging a plaintext database because the software expected the record identifiers to be tokenized a certain way, but the original data source had spaces in those strings.

                    The software was the ISC DHCP server, the industry standard for decades and only EOL’d a year ago.