-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
scripts: follow up of #3115 (feedback) #3124
Conversation
@@ -1,5 +1,7 @@ | |||
#!/bin/bash | |||
|
|||
shopt -s globstar |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided against this for two reasons:
- The effects of
shopt
are 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 on
Hence, 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/
)