I hope I'm posting this in the right place, since it it's really a
feature request, rather than a bug report. However, here are a few
things which I think would be nice to have in bash, and easy to implement:
1)substr support for a negative length argument.
For example,
stringZ=abcdef
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.
There is a also a realpath program, but it seems not to be part of bash
by default:
http://src.opensolaris.org/source/xref/sfw/usr/src/cmd/bash/bash-3.0/examples/loadables/realpath.c
---------------------------
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 is ../../b/c
How could a shell script calculate this?
---------------------------
5)An enhancement to read/readline, such that one can specify the initial
value with which the buffer is filled.
Currently, we can do:
read -ep 'Enter your name: ' NAME
and I might type "Richad Neill". #Note the deliberate typo.
If the script recognises this as invalid, the best it can do is:
echo "Name not recognised"
read -ep 'Re-enter your name: ' NAME
and the user must retype it in full.
I'd like to propose adding an "-i" option for initial value:
echo "Name not recognised"
read -ep "Please correct your name: " -i "$NAME"
The shell prints:
Please correct your name: Richad Neill
where the latter part is now editable.
Thus the really nice editing features of readline can be used for
updating values already stored in variables. This is extremely useful
when the value is quite long.
---------------------------
I hope these thoughts are of some use. I'm not on this list, so please
CC me with any followup. If this report could have been more useful, I'd
welcome any feedback.