Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


  mv foo \!\'


Better:

  $ 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).


Yep, 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.


I 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.


I 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: