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
Use double quotes for remove_temporary_mountpoint "$BUILD_DIR/..." #2675
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bdb70d6
Update _input-output-functions.sh
jsmeix 190cf10
Update global-functions.sh
jsmeix f930748
Update global-functions.sh
jsmeix dcb5ef3
Update global-functions.sh
jsmeix 2965acf
Update global-functions.sh
jsmeix c8221eb
Update global-functions.sh
jsmeix File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
don't you also need to quote
$scheme
in callers? In principle it should work even without quoting, because this function takes only one argument, but it will cause problems whenset -eu
is used ($1
can be undefined).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.
for consistency, I think that the same thing should be added to
scheme_accepts_files()
above.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 use it without quotes to not let it falsely succeed if $scheme is blank:
I do no longer really care about
set -eu
because that caused much more false exits
than it benefits in practice.
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.
And it should also fail if scheme is more than one word
That doesn't look nice but actually it is perfectly right
to have that bash stderr message.
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.
Cf. "Beware of the emptiness" in
https://github.com/rear/rear/wiki/Coding-Style
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.
Implemented via
2965acf
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 think I found out why if failed above with
bash: $2: cannot assign in this way
."man bash" reads (excerpt)
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.
in general yes. but I think in case of quoting of parameters that can expand to empty strings or whitespace I would add quotes to the caller, because in general this can not be always compensated for inside the functions (imagine a function with more parameters, $scheme being the first of them - if it is empty, the others will shift - this is the case of
output_path()
andbackup_path()
functions here) and it is better to consistently give a correct example if the particular case does not strictly require it (other will copy and adapt the code). (I should have remembered this rule when writing the code and use quotes everywhere - I did not realize that$scheme
may be empty.)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.
that must be it. Ans as in ReaR function arguments get quite consistently saved to local variables with more descriptive names at the start of every function (which is a good practice), it is not a big limitation.
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 fully agree with you that callers should call functions in a correct way.
I only meant that first and foremost the functions itself should be fail-safe.
Of couse I know that currently most functions in ReaR are not fail-safe.
E.g. a function that requires two arguments should check that it actually got
exactly two valid arguments so that when a caller provides something different
the function could do "the right thing".
What "the right thing" is depends on the particular function.
That bash parameter expansion with using a default value
is OK for our needs is what I meant with my comment
that is currently at
https://github.com/rear/rear/blob/jsmeix-fix-issue-2667/usr/share/rear/lib/global-functions.sh#L352