4 ms·
Handling of special character is usually a bigger problem than unicode. Just today, I tried to name a file with both a single quote and an exclamation point fro
by j-kidd 14y ago
Handling of special character is usually a bigger problem than unicode. Just today, I tried to name a file with both a single quote and an exclamation point from bash shell. Ended up doing that with a GUI file manager.
- qb45 14y agomv foo \!\'
- pyre 14y agoBetter: $ touch 'j-kidd'\''s file!' $ ll 'j-kidd'\''s file!' -rw-rw-r-- 1 uid gid 0 Apr 11 13:30 j-kidd's file! History expansion will happen on the ! in double quotes: $ ls "!$" ls "'j-kidd'\''s file!'" ls: cannot access 'j-kidd'\''s file!': No such file or directory It won't happen on single-quotes: $ ls '!$' ls: cannot access !$: No such file or directory The only issue is that you can't escape a single-quote within single quotes, so you have to do one of these '\'' (escape a single-quote block, a literal single quote, start a new single quote block).
- qb45 14y agoYep, that's an important and maybe non-obvious behavior of the shell: "directly adjacent strings which are double quoted, "'single quoted or even'\ unquoted\ and\ possibly\ full\ of\ escape\ sequences\ 'get concatenated and count as a single parameter.' Running touch on the above will create one file with very long name.
- kzrdude 14y agoI was going to question you about that, but then I realized I, too, want computers to handle natural language filenames. Or, "don't be your computer's tool!" -- the operator should accept no arbitrary limitations.
- btilly 14y agoI usually wind up calling Perl for that kind of stuff. That also lets you write confusing filenames like "foo\rbar". Which can be really irritating to figure out without a GUI.