Mikkel L. Ellertson wrote:
If you are using a varable in a loop, and its value only has meaning in that loop, but not in the rest of the script, use a lowercase name. For example:
for name in *.txt ; do file $name done
For small scripts, it is not too important, unless you do something like ". <script name>" or "exec <script name>" from inside another script. Then any changes made to a varable in the sourced script affect the calling script.
If the name is upper case, then I know it is ether a shell varable, or it is set at the start of the script, and has the same value in the entire script. For example, I know MAIL is a shell varable pointing to the user's mail spool, and EDITOR, if it is set, is the user's preferred text editor. And if I see $SED, I know that it is the full path to sed, or a program that will act like sed when used in the script. If I see $name, I know to look for where it is set in the script. It should be fairly close to where it is used. If I see $Name, then I know may I have to look farther back in the code to see where it get set. I also know that I have to be carefull about how I change it.
Mikkel
OK. I see what your system is. It makes sense, but it may add an element of complication where it is not needed. Since there is no practical restriction on the length of variable names that I know of, I simply make sure that I have no duplicates and that I do not invoke subshells which do not initialise their variables correctly.
Thanks for all your, as usual, enlightening comments. I think this thread is going too far away from "newbie" interest, though.
regards Duncan
____________________________________________________ Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com ____________________________________________________
