A little Unix difference that irritates: what word erase erases
I (still) use a number of different Unixes. For the most part they aren't particularly different in day to day use, but it turns out that there is one little difference that really gets to me. That is what TTY word erase (usually Ctrl-W) erases, or the other way to put it, what it stops erasing at.
In most environments, what C-W considers to be a 'word' is 'everything back to the previous whitespace' (or the start of the line if this is the first word on the line). Suppose that you're typing this:
$ cd /some/whre
The cursor is at the end of the line and you hit C-W; you'll erase
all of the
/some/whre, going back to the whitespace between the
cd and it.
But on some systems, C-W also breaks words at some non-alphanumeric
characters; I'm not sure what characters exactly, but they definitely
/'. On these systems if you hit C-W at the end of our sample
line, you will just erase the
whre and be left with '
cd /some/' (if
you then hit C-W again it erases '
some/', so cleverness is going on).
(This may be a Linux-only behavior, since that's the only thing I can reproduce this on right now.)
It turns out that the second behavior is much more convenient for me. When I'm erasing words, I almost always want to consider the various components of a long path to be separate words; if I want to get rid of the full path, hitting C-W a few times is fast, and if I just want to erase and retype the last component because I've made a mistake in it (as in this example) that's something I can actually do. With the whitespace-only model of word erase it's much more irritating to make a mistake in a path or the like.
Of course this is basically irrelevant to most people these days. This word erase behavior only applies if you're relying on the kernel's handling of line input. Most people are using shells with built in command line editing (and the programs they use will often use readline); in those programs, word erase behaves however the program or library wants it to. I'm an exception because my shell doesn't have command line editing.
(In bash, word erase seems to be 'erase to whitespace'. There is probably some readline control or option for changing this, since readline has a huge collection of customization options.)
Comments on this page:Written on 22 November 2012.