You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
We need to better structure our bash support code #5844
Currently we store most of our support functions for bash in hack/util.sh (800+lines) and hack/common.sh (600+ lines). I think the approach upstream has merit, so I think we should
It does involve touching every other bash script - in the long term, are
there other cleanups in bash that reduce the need for bash more? Reduce
our dependence on certain things in util? I'm always a fan of cleanliness,
but it's good to do it while also reducing the cost of long term
maintenance. Bash has some level of unintended consequences when you
refactor it (because it is not as free of side effects as it should be).
It helps to frame these refactors in terms of "if I change this, this
becomes much easier".
On Nov 11, 2015, at 5:26 AM, Steve Kuznetsov [email protected]
wrote:
Currently we store most of our support functions for bash in hack/util.sh
(800+lines) and 'hack/common.sh(600+ lines). I think the approach upstream
has merit, so I think we should 1) divide our utility functions into
functional files (thinkbuild.sh,util.sh`, etc) 2) ensure that they all
are correctly namespaced as a result, and 3) move them into a new
directory structure like the following. Tests for the functions can live in
a parallel structure.
hack
├── bin
│ ├── build.sh
│ ├── junit.sh
│ ├── testwrappers.sh
│ └── util.sh
└── test
└── testwrappers_test.sh
The value-adds that I see from a restructure/cleanup are:
it's easy to read the helper function libraries
we can import with more specificity
we can easily see which functions do and do not have tests
it becomes easier to create a new utility script and stick reusable code there
I know with one or two monolithic utility functions I have hesitated to add code to them, knowing that 99% of scripts sourceing them won't need whatever utility function I am adding, even though there may be 10 that do.
The effort to do this is fairly minimal so I think it should be a straightforward task with some concrete wins for little work. As you say this does entrench us further into using bash, but I'm not entirely sure what our alternative is - writing tiny golang executibles?
Another value add can come from updating our current bash to reflect best practices as reported by tools like ShellCheck. A cursory run of this over some of our scripts reveals quite a large amount of potential errors. I'm not sure we need to include it as a vetter in our CI for bash PRs but it's definitely got a lot of good checks.
Activity
deads2k commentedon Nov 11, 2015
I don't think that I'd want to follow upstream off the bash cliff unless we have to.
stevekuznetsov commentedon Nov 11, 2015
I hardly think that these changes would vault us off that cliff.
smarterclayton commentedon Nov 11, 2015
It does involve touching every other bash script - in the long term, are
there other cleanups in bash that reduce the need for bash more? Reduce
our dependence on certain things in util? I'm always a fan of cleanliness,
but it's good to do it while also reducing the cost of long term
maintenance. Bash has some level of unintended consequences when you
refactor it (because it is not as free of side effects as it should be).
It helps to frame these refactors in terms of "if I change this, this
becomes much easier".
On Nov 11, 2015, at 5:26 AM, Steve Kuznetsov [email protected]
wrote:
Currently we store most of our support functions for bash in hack/util.sh
(800+lines) and 'hack/common.sh(600+ lines). I think the approach upstream
has merit, so I think we should 1) divide our utility functions into
functional files (thinkbuild.sh,util.sh`, etc) 2) ensure that they all
are correctly namespaced as a result, and 3) move them into a new
directory structure like the following. Tests for the functions can live in
a parallel structure.
hack
├── bin
│ ├── build.sh
│ ├── junit.sh
│ ├── testwrappers.sh
│ └── util.sh
└── test
└── testwrappers_test.sh
/cc @smarterclayton https://github.com/smarterclayton @dmcpherson
https://github.com/dmcpherson
—
Reply to this email directly or view it on GitHub
#5844.
stevekuznetsov commentedon Nov 11, 2015
The value-adds that I see from a restructure/cleanup are:
I know with one or two monolithic utility functions I have hesitated to add code to them, knowing that 99% of scripts
sourceing them won't need whatever utility function I am adding, even though there may be 10 that do.The effort to do this is fairly minimal so I think it should be a straightforward task with some concrete wins for little work. As you say this does entrench us further into using bash, but I'm not entirely sure what our alternative is - writing tiny golang executibles?
stevekuznetsov commentedon Nov 12, 2015
Another value add can come from updating our current bash to reflect best practices as reported by tools like ShellCheck. A cursory run of this over some of our scripts reveals quite a large amount of potential errors. I'm not sure we need to include it as a vetter in our CI for bash PRs but it's definitely got a lot of good checks.
smarterclayton commentedon Nov 12, 2015
It would be good to at least make it easy to run.
On Nov 12, 2015, at 4:39 PM, Steve Kuznetsov [email protected]
wrote:
Another value add can come from updating our current bash to reflect best
practices as reported by tools like ShellCheck http://www.shellcheck.net/.
A cursory run of this over some of our scripts reveals quite a large amount
of potential errors. I'm not sure we need to include it as a vetter in our
CI for bash PRs but it's definitely got a lot of good checks.
—
Reply to this email directly or view it on GitHub
#5844 (comment).
stevekuznetsov commentedon Apr 8, 2017
We're mostly there.