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

2009-01-15 Thread Pierre Gaston
On Thu, Jan 15, 2009 at 8:14 AM, Chris F.A. Johnson
 wrote:
> On 2009-01-15, Jan Schampera wrote:
> ...
>> 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.
>
> man bash4:
>
> ... the ^ and , expansions match and convert only the first
> character.

Like that it maybe clear, but since it comes after the definition that
says "each matched characters"
and after the // expansion where a single / means the first match,
it's not difficult to think that
"first character" means "the first matched character" and that matched
has just been omitted.

Imho it would more simple, more intuitive and probably more powerful
if ^^ and ,, were working just like //.




Re: truncating the path in the bash prompt?

2009-01-15 Thread Matthew Woehlke

Paul Jarc wrote:

Matthew Woehlke  wrote:

Actually, a feature that would be REALLY helpful is a way to specify
certain directory strings that should be abbreviated.


PS1='...$(mypath)...'
mypath() {
  case $PWD/ in
/usr/local/src/kde/svn/trunk/*)
  printf %s "${PWD/#\/usr\/local\/src\/kde\/svn\/trunk/\$src\$}";;
/usr/local/build/kde/svn/trunk/*)
  printf %s "${PWD/#\/usr\/local\/build\/kde\/svn\/trunk/\$build\$}";;
*) printf %s "$PWD";;
  esac
}


Yike. Okay, but if that's possible, what's the point of PROMPT_DIRTRIM? :-)

Anyway, I like this better:
PS1="...\$(mypath  \"\w\")..."

:-)

--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
"Doggy!" -- Robots from Freefall (http://freefall.purrsia.com)