[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: slight OT: shell-script programing style -- origins and change?
From: |
Marc Herbert |
Subject: |
Re: slight OT: shell-script programing style -- origins and change? |
Date: |
Tue, 27 Oct 2009 09:15:14 +0000 |
User-agent: |
Thunderbird 2.0.0.21 (X11/20090320) |
Stephane CHAZELAS a écrit :
> By convention, _environment_ variables are upper-case, which helps
> in a shell script to distinguish them with ordinary variables. I
> would consider shell scripts with all upper-case variables to be
> poorly written, and I agree with the fact that it looks like
> yelling and is less easy to read.
> It's OK to use upper-case for environment variables as you
> generally want to have the environment as small as possible.
This looks indeed like a larger Unix tradition than just a shell script
one. John mentioned C macros, but Sun's Java conventions also recommend
UPPER_CASE for constants. Hasn't Perl the same convention?
Here I purposely confuse globals and constants since they overlap a lot
in practice (the less mutable are the globals, the safer).
In languages lacking actual namespaces it is a useful convention to have
all globals isolated into the well-known "upper case namespace".