[Top][All Lists]

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

Re: Bash - various feature requests

From: Matthew Woehlke
Subject: Re: Bash - various feature requests
Date: Wed, 03 Jan 2007 19:36:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/20061206 Thunderbird/ Mnenhy/

Richard Neill wrote:
1)substr support for a negative length argument.
For example,
  echo ${stringZ:2:-1}  #prints cde

i.e. ${string:x:y}
  returns the string, from start position x for y characters.
  but, if x is negative, start from the right hand side
  and if y is negative, print up to the end, -y.

This would work the same way as PHP, and be extremely useful for, say, removing an extension from a filename.

Sounds good, but your example is bad... how do you know how long the "extension" is? :-) Consider 'foo.txt', 'bar.tar.gz', 'core.1234', etc. But this would be useful for other things, I would think.

4)A way to find a relative directory path. i.e. the solution to:

   If I were to start in directory  /home/me/x/y/z
   and I wanted to get to /home/me/x/a/b/c

   then, what argument would I need to provide to 'cd' ?

Answer: /home/me/x/a/b/c. Well, the shell's built-in may do the "obvious" thing, but if you are expecting to feed paths to programs this way, symlinks will come and bite you. :-) There a quite a few places "in" my home directory where '../foo' and ( cd .. ; ./foo )' are not equivalent.

5)An enhancement to read/readline, such that one can specify the initial value with which the buffer is filled.

Well, that, and a way to specify possible completions. :-)

"But I want to cast Magic Missile!"

reply via email to

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