> Would it work if the dir is mounted remotely on another OS?
If the other OS implements the feature. Most likely not. Is custom icons for directories even a thing on Linux? I'd assume not since there are a gazillion file managers/browsers.
> Bad design on someone's part I'ld say.
It's very rare so hardly an issue. The format of that file is poorly documented so most developers don't know how to make one even if they want to (I happen to be one of the small subset of power users / developers who actually looked into this format). Hidden by default too so most people never notice them. Besides, I'm doubtful that a central registry is better suited for this purpose. How would you allow a custom icon for any directory, that is persisted across duplication, network shares, etc.? Directories can't have resource forks AFAIK so you have to use a file inside.
If you want to see an example of an actual fucked up design in macOS's file browser, google `.DS_Store`.
Well, since you set out to replicate `ls --quoting-style=literal`, you can just do
```
if ((*buf >= '\x01' && *buf <= '\x1f') || *buf == '\x7f')
```
and call it a day. FWIW I've never seen ESC in a filename either, except by mistake.
> we didn't have to check each character because all but ESC fall in a range.
>
> if ((*buf >= '\a' && *buf <= '\r') || *buf == '\e')
Actually, that's not true. The full set of control characters is `00`–`1F` plus `7F`.
Bash has no builtin file listing facilities. If you mean ls, it's not that simple. The default behavior of coreutils ls(1) changed in 8.25, where the default quoting style became `shell` when stdout is a tty, so by default `$'Icon\r'` is printed as `'Icon'$'\r'`. You apparently don't want that. Judging from your transcripts, you're either using 8.24 or earlier, or your ls is aliased with `--quoting-style=literal`. But there are other equally valid and more informative quoting styles, e.g., `escape`, where `'$'Icon\r'` would be `Icon\r`, `$'1\a2'` would be `1\a2`, etc (basically, ANSI-C quoting without the quotes).
I didn't read the code but what's the problem with replacing them with two characters? Allocating another buffer? I mean, however non-printable characters are currently escaped, you can do this the same way, no?
CI failure is not my fault:
```
==> Installing or updating 'rubocop' gem
Building native extensions. This could take a while...
Error: The 'rubocop' gem is installed but couldn't find 'rubocop' in the PATH:
```
<img width="235" alt="screen shot 2017-05-02 at 11 08 20 pm" src="https://cloud.githubusercontent.com/assets/4149852/25647007/43644ec4-2f8c-11e7-9561-190ea582737c.png">
That blank line should be a `$'Icon\r'`. The CR is probably printed unquoted, so the line is overwritten.