Fix Word Splitting and some minor improvments#3
Open
harmathy wants to merge 5 commits into
Open
Conversation
Add shebang to indicate, that this script is a posix sh shell script. This eliminates relying on implicit wrapping of commands into some shell by docker and allows static analysis with shellcheck.
This changes eliminates several issues with paths containing spaces. First of all variables are now properly quoted. Then iteration over find output takes an intermediate step with a temporary file to avoid word splitting in a path. The call to head -c 1 is replaced by printf, which is probably a shell built-in and thus might save an external process call. The outer iteration over the result of extract has moved from the create_dir function to a main function.
Author
|
Another possibility would be, to switch to bash and utilize its arrays, since the script requires ldd, which itself requires bash anyways. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
These changes mainly address issues #2 with word splitting. The solution, using temporary files for storing the find output, is described in the Shellcheck Wiki. It isn't very clean, IMO. But posix shell obviously doesn't offer very much help here.
There is a Github Action, which runs
shellcheckfor static analysis, which helps preventing such issues.And also there are some minor improvements.