1. 10

  2. 53

    Technically, yes, it counts as a solution.

    Let us never speak of it again.

    1. 4

      Personally, I’d rather avoid quirks like this and just use _ or -.

      1. 4

        How about not using spaces in filenames in the first place?

        1. 6

          I get this on Unix, where the pissweak tooling is a disaster, but as a user, I own the file name. If I can’t use every character I want to, that’s a total fail on the part of the platform.

          1. 5

            I agree that you own the filename and should be able to use any characters you want, but there has to be some trade off regarding what filenames you can use in a comfortable manner and which require some form of escaping/quoting.

            Another weird character would be the tilde (~). Technically a valid character in a filename, but whenever I see one I begin to fear that I might delete or mess with my home folder.

            1. 5

              The tilde is a perfectly fine character to use in a filename, it’s just the shell that does the expansion to your home directory if you give “~ “ (or “ ~ /” at the start of a path). My preferred editor marks the backup file with “~” (at the end of the filename).

              Edit: ~ is a “special” Markdown character. No comment on that.

              1. 2

                I mean, I don’t use spaces, or tildes, or dollar signs (or colons, for HFS+) in any files that I create or expect to manipulate on the command line, but that doesn’t mean it’s OK. I want the compromises that my computer and I make to live with one another to be largely the province of the computer.

                1. 1

                  You can say that about other characters, too - *, ;, ?, etc. not just ~.

                  If in doubt, quote or escape :^)

                2. 2

                  Unlike on other operating systems (well, file systems to be precise), you actually can use any character - even newline or NULL if you so wish. The problem is that you also have to use something as a separator - it so happens that a blank is a natural way to split words apart :^)

                  So yes, you have to escape or quote blanks and other characters which are extra special ;^)

                  1. 1

                    Obviously not Null :^P - I was thinking of Null as used by find ... -print0 and xargs -0. I should probably get some sleep ;^)

                3. 1

                  Or just use spaces and escape them? It’s not hard, and escaping occurs literally everywhere strings are used.

                  zsh tab completion auto-escapes. GUI programs don’t need to worry about it. I have plenty of filenames with spaces in them, and they don’t cause problems for me.

                4. 3

                  Can you imagine the debugging caused by someone using this hack.

                  1. 2

                    Non breakable spaces were (are?) often used in HTML to avoid text reflows around punctuation (good typography actually), and too many other hacks to avoid line breaks.

                    Not sure I’d welcome these in a terminal. 🤔

                    1. 2

                      What if they were coloured differently?

                      1. 0

                        Wouldn’t that defeat the purpose?

                        1. 1

                          Yes, if the purpose is to annoy and confuse people.

                          Do you believe the only reason people have spaces in filenames is to annoy and confuse?

                          Do you believe it is even a common reason?

                    2. 2

                      Part of that is the unique nature of the space character. In ASCII, it’s grouped next to the information separator characters and thus, could be treated as another type of separator character (and on input, it usually is considered such).

                      This is sort of true but leads to an incorrect justification. Space is next to information separator characters (properly: “control characters”) but is grouped with the printable characters. It’s next to the control characters to make sorting easier (“a a” ahead of “aa”), not so that it’s a quasi-control character. Look at an old chart and it’s apparent ASCII’s designers were thinking in terms of bit twiddling for ranges, not proximity. Yes, space has long been used as a separator, but it’s definitely not designated as such in ASCII - compare to the tab character (HT in that chart).

                      This post is a fun workaround for a limitation in make, though.

                      1. 2

                        For me, the space-in-filenames issue is the main thing preventing me from using Make for everything. The limitations on pattern rules make scaling up Makefiles difficult, too.

                        I’ve long thought that a prolog-like DSL would be perfect; makefiles are basically already logical specifications—I just needed something that worked with spaces and could perform some sort of unification-like process for smarter pattern rules. I nearly started writing my own.

                        But then I discovered that someone already created such a tool: biomake. I’ve recently started using biomake to automate a large data science research project. It has been absolute bliss! Not only does it those two pain-points with using Make (and countless other pain-points), it features GridEngine integration out-of-the-box, and fantastic debugging information for when things don’t work as expected. I cannot see myself using any other tool.

                        1. 2

                          There is very little difficult with spaces in filenames. Learn to quote. Learn to escape. Then everything is very easy.

                          1. 1

                            It seems like you either didn’t read the linked post or didn’t understand it.

                            The issue there was with make not being able to handle spaces in file names - neither quoted nor escaped.

                          2. 0

                            Quotes and backslashes seem to solve this problem without special characters

                            1. 5

                              Not everywhere. The original post mentioned make having a difficult time with spaces, and no amount of quoting or escaping seemed to work with it. Not that I go around making source files with spaces in the name, but that’s one place where your solution doesn’t work.