Chet Ramey wrote: >> The case modification operators (for parameter expansion) seem to be >> puzzled. >> >> Two things I don't understand: >> - it seems to work word-wise (might be due to my misinterpretion of the >> default pattern) > > It does work word-by-word, like the emacs-mode editing commands. I > would like feedback on whether or not that works better than the > alternative.
Intuitively I expected it to operate on the whole content, not word by word. On the other hand, I have no big clue about emacs and the Bash emacs-mode, so other people might expect it to work like that. It doesn't really matter for scripting, because either behaviour can be used to simulate the other (using a loop etc..). IMHO the technical more intuitive version (working on the whole content rather than splitting it into words) should be used. There will be less surprises for the scripters and less surprises when using fancy patterns. Also, when it works word by word, it should be 1000% clear what's treated as a word separator. It took me some time to get it, because I first experimented with PATH :) Moreover, word separators might depend on the locale which will have typical locale effects, too. Again, I think the basic way of seeing the content as a whole is the clean and straightforward way for the implementation of such an operator. Much text, but you asked for feedback ;) I have another one, maybe my misinterpretion or an unclean documentation: $ TEXT="Test" $ echo ${TEXT^s} Test I expected "TeSt", since the pattern is "s", and the 3rd letter in "Test" matches that, and should be changed. Interesting that it works with ^^s (for "Tesst" then), but for all "s", of course. It tastes like a bug or a wanted, but non-intuitive implementation. The vice versa case ("tESST" and ,S) behaves analog. -- This is my life - this is my net! - Jan