Wed 09 Nov 2005 04:21:27 AM UTC, original submission:
Some of the bash string functions are unintuitive, to say the least. For example
${#VARIABLE}
is not, to my mind, as clear as
strlen $VARIABLE
Likewise,
${stringZ/abc/xyz}
would be much easier to understand if written as
strreplace stringZ abc xyz
It would also be easier to handle metacharacters this way, and easier to look up "help strreplace".
What I am requesting are a few predefined fucntions (substr, strlen, etc) that refer to the normal bash string handling, but with a less gruesome syntax.
My suggestion is that, by introducing these now, in 5 years' time it may be safe to use them in most shell scripts, and then one of the annoyances of bash will be gone.
I think that the performance penalty would be almost zero, but the result would be a large increase in readability. Of course, the old ways wouldn't vanish.
Naturally, this is just a personal view, but I do quite a bit of bash scripting, and even I never remember all of these!
If you disagree, perhaps implementing "help string" or "help substr" etc would be a good alternative. Thus documenting the functions that don't exist, but that people are looking for, and giving a pointer to where they might be found.
Thanks very much for all your work - much appreciated.
|