Re: [PATCH 12/30] subtree: don't have loose code outside of a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 23 Apr 2021 14:23:18 -0600,
Eric Sunshine wrote:
> 
> On Fri, Apr 23, 2021 at 3:43 PM Luke Shumaker <lukeshu@xxxxxxxxxxx> wrote:
> > Shove all of the loose code inside of a main() function.
> >
> > "Ignore space change" is probably helpful when viewing this diff.
> >
> > Signed-off-by: Luke Shumaker <lukeshu@xxxxxxxxxxx>
> 
> What is the purpose of this change? Does some subsequent commit depend
> upon this or is it just a personal preference? The commit message
> explains the "what" of the change but not the "why".

Dropping the commit would surely cause me much trouble with rebasing
both the subsequent commits in this patchset and the commits I haven't
yet submitted.  But I don't think they "depend" on it.

I guess it is personal preference... one that I've developed from
years of maintaining Bash scripts.  It's in a nearby part of my brain
to "avoid global variables".  It's related to my notion that the
reason most people think shell scripts are so terrible is that most
people don't treat it like a real programming language and don't apply
normal programming best practices; that not littering code around
outside of a function is part of treating it like a real language (at
least once the program grows beyond a certain size, which git-subtree
surely has).  It's probably related to the Python idiom

    if __name__ == "__main__":
        main()

that is often seen at the bottom of Python scripts.

In this specific case, it's also moving the `set -- -h`, the `git
rev-parse --parseopt`, and the `. git-sh-setup` to be closer to all
the rest of the argument parsing, which is a readability win on its
own, IMO.

-- 
Happy hacking,
~ Luke Shumaker



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux