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:Mikkel L. Ellertson wrote:
lower case names for local varables - so you don't break things if you deside to source the code from another script.
Mikkel,
Explain this to me, I don't quite follow your rationale here.
I always use upper case for variable names so they can be clearly seen as such when one reads the scripts at a later stage.
regards Duncan
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 --
Do not meddle in the affairs of dragons, for you are crunchy and taste good with Ketchup!
____________________________________________________ Want to buy your Pack or Services from MandrakeSoft? Go to http://www.mandrakestore.com Join the Club : http://www.mandrakeclub.com ____________________________________________________
