[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bash-testers] Re: case modification operators misbehaviour?

From: Jan Schampera
Subject: Re: [bash-testers] Re: case modification operators misbehaviour?
Date: Thu, 15 Jan 2009 06:52:15 +0100
User-agent: Mozilla-Thunderbird (X11/20090103)

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}

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]