scripts: follow up of #3115 (feedback)#3124
Conversation
| @@ -1,5 +1,7 @@ | |||
| #!/bin/bash | |||
|
|
|||
| shopt -s globstar | |||
There was a problem hiding this comment.
Can this introduce unwanted side-effects with our existing scripts that are called afterwards?
Another option would be, to just use it in the _setup function.
Edit: After a quick grep, we don't seem to use '**/' anywhere else.
There was a problem hiding this comment.
I was wondering about this too. But I left it up to the tests. Seems there is one place we need to adjust. I will do this later.
There was a problem hiding this comment.
Nevermind, was a sporadic BATS issue.
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
I decided against this for two reasons:
- The effects of
shoptare not scoped to a function, i.e.
$ cat test.sh
#!/bin/bash
shopt -u globstar
shopt | grep "globstar"
function a() {
shopt -s globstar
shopt | grep "globstar"
}
a
shopt | grep "globstar"
$ bash test.sh
globstar off
globstar on
globstar onHence, setting this inside the whole setup, i.e. changing the behavior at a certain point, is undesirable. We could turn it off again, but actually setting it as fine I think; we may be able to use it in the future and it does not hurt at all.
2. I want Bash adjustments like shopt or set to be used at the very beginning of scripts so everyone immediately notices them. I plan on introducing set -u and shopt -s inherit_errexit too, and these should go together at the beginning start-mailserver.sh.
There was a problem hiding this comment.
I am aware of that. I didn't express it clearly enough. I meant something like this:
function foo() {
shopt -s globstar
for i in /foo/**/*; do
bar
done
shopt -u globstar
}
Setting globstar in the function and revert it after usage.
There was a problem hiding this comment.
I actually think that this feature is useful in general, and having it available everywhere is a nice thing :)
| @@ -1,5 +1,7 @@ | |||
| #!/bin/bash | |||
|
|
|||
| shopt -s globstar | |||
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Description
Follow-up of #3115 (branch name of this PR wrong, lol). See
#3115 (comment) for example.
Type of change
Checklist:
docs/)