Convention/standard for naming files, functions and variables
matthew at linuxfromscratch.org
Sat Jan 3 10:44:17 PST 2009
On Sat, 3 Jan 2009 19:50:37 +0200, "Angel Tsankov" <fn42551 at fmi.uni-sofia.bg> wrote:
> Matthew Burgess wrote:
>> On Sat, 3 Jan 2009 04:08:26 +0200, "Angel Tsankov"
>> <fn42551 at fmi.uni-sofia.bg> wrote:
>>> I'd also like to know how to name functions in shell scripts,
>>> which environment variables should be lowercase and which should be
>> Naming functions in shell scripts should really follow the standard
>> programming convention of calling them by the verb(s) that most
>> describe what the function does. e.g. truncate(), replace(), find().
> That's reasonable, but if the name contains more than one word do you use
> lowerCamelCase, underscores, hyphens or smth else to separate the words?
I happen to use lowerCamelCase.
>> As for environment variables, standard convention is to have them in
> With underscores delimiting the words, right?
>> Again, I'm not sure there's any particular convention or even a style
>> guide for this. There are some brief points at
>> http://tldp.org/LDP/abs/html/unofficialst.html though.
> Well, I think that there should be conventions for all sorts of things,
> 'cause conventions make life easier (or at least they should do so).
Oh, as do I, but then trying to get people to adopt such conventions or
even agree on what those conventions should be in the first place will
lead to very long flamewars as do any subjective discussions.
Personally, I'll accept any style guide thrown my way (explicitly
defined or implicitly visible in an existing codebase); it's better for
my code to be consistent with the rest of whatever code I'm working on
than to be consistent with my own opinion of what looks/reads better.
> Does anybody have an idea why peope would mix underscores and hyphens like
> this: libpng-1.2.8-link_to_proper_libs-1.patch?
That's explained at http://www.linuxfromscratch.org/patches/submit.html.
Basically, there are 4 fields in the filename, each separated by '-'.
Therefore, any long/multiple words in the description field (3rd) are
separated by '_' so as not to confuse them as additional fields.
More information about the lfs-chat