The Boston Diaries

The ongoing saga of a programmer who doesn't live in Boston, nor does he even like Boston, but yet named his weblog/journal “The Boston Diaries.”

Go figure.

Wednesday, February 28, 2018

Notes on an overheard conversation while driving south along I-95

“When are they going to finish all this contruction? The road here is terrible!”

“It keeps the drivers on their toes.”

“The lanes are all uneven! It could force you into the next lane!”

“Yes, that's what makes it exciting.”


A potential way to have spaces in filenames and not break the Unix command line

A thread at Hacker News about using makefiles for JavasScript was about the difficulty in using filenames with spaces. And yes, it is difficult. A Makefile such as:

hello world:

Results in:

[spc]lucy:/tmp/foo>make
make: Nothing to be done for `hello'.
[spc]lucy:/tmp/foo>

Enclosing the filename with quotes (single or double, it doesn't matter) gives the same results. If I escape the space like:

hello\ world:

make gives:

[spc]lucy:/tmp/foo>make
cc     hello world.c   -o hello world
cc: hello: No such file or directory
cc: world.c: No such file or directory
cc: world: No such file or directory
cc: no input files
make: *** [hello world] Error 1
[spc]lucy:/tmp/foo>

So yes, using a filename with spaces is problematic with make. 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). It could also be considered a control character as a format effector such that it causes the character position to advance one place to the right (and is thus used as such with output).

It's the prevasive use of space as a separator in Unix that causes the most issues, such with make, and the command line in general.

But there is a solution …

[spc]lucy:/tmp/foo>ll
total 12
-rw-r–r–  1 spc spc  14 Feb 28 18:13 Makefile
-rw-r–r–  1 spc spc  76 Feb 28 18:13 hello world.c
-rw-r–r–  1 spc spc 227 Feb 28 18:13 x.lua
[spc]lucy:/tmp/foo>cat Makefile
hello world:
[spc]lucy:/tmp/foo>make
cc     hello world.c   -o hello world
[spc]lucy:/tmp/foo>./hello world
Hello, world!
[spc]lucy:/tmp/foo>

No, the output is not faked. Yes, the filename is hello world.c. The name, however, is not pure ASCII—it contains the Unicode character for a “non-breaking space”. Cheating? Perhaps. But it is defined as a space (graphically), and more importantly, it's not considered an information separator by Unix utilties. It also requires a filesystem that can support Unicode (or in my case, UTF-8) and a command line that also supports Unicode (or again in my case, UTF-8). And it was also not that easy to create the filename and Makefile with the non-breaking space.

But other than those minor issues [Ha! —Editor], hey—spaces! In filenames!

Obligatory Picture

An abstract representation of where you're coming from]

Obligatory Contact Info

Obligatory Feeds

Obligatory Links

Obligatory Miscellaneous

Obligatory AI Disclaimer

No AI was used in the making of this site, unless otherwise noted.

You have my permission to link freely to any entry here. Go ahead, I won't bite. I promise.

The dates are the permanent links to that day's entries (or entry, if there is only one entry). The titles are the permanent links to that entry only. The format for the links are simple: Start with the base link for this site: https://boston.conman.org/, then add the date you are interested in, say 2000/08/01, so that would make the final URL:

https://boston.conman.org/2000/08/01

You can also specify the entire month by leaving off the day portion. You can even select an arbitrary portion of time.

You may also note subtle shading of the links and that's intentional: the “closer” the link is (relative to the page) the “brighter” it appears. It's an experiment in using color shading to denote the distance a link is from here. If you don't notice it, don't worry; it's not all that important.

It is assumed that every brand name, slogan, corporate name, symbol, design element, et cetera mentioned in these pages is a protected and/or trademarked entity, the sole property of its owner(s), and acknowledgement of this status is implied.

Copyright © 1999-2024 by Sean Conner. All Rights Reserved.