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
utils(dep_tree2sql): Update to valid syntax, address shellcheck warnings #3547
Open
echoix
wants to merge
13
commits into
OSGeo:main
Choose a base branch
from
echoix:dep_tree2sql_shell_fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
… command substitution
…res 9.2 and up (released september 2012)
…-alphanumeric filenames
This has a change in the paths returned, as they start with ./ instead
-perm +mode was deprecated in favor of -perm /mode. It checks if any of the permissions bits in mode is set. It is thus replaced by the equivalent check of "any file that has the executable bit set for anybody"
…y, that can be properly quoted in the call below
Using `shfmt -w -s -i 4 -ci -bn -sr`
This will need a shell/bash-knowledgeable reviewer. |
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.
I incrementally updated the utils/dep_tree2sql.sh script first to address some easy shellcheck suggestions, but it ended up being a bit more touchy, so I made this a PR by itself.
The initial state of this script was that it wasn't completely working anymore in modern shells (bash in Ubuntu 22.04).
The way I proceeded: I made a single change, dumped the database to a SQL script (
pg_dump grass > dumpfile.sql
), checked the diff, and continued to a further change. I also explored the various example queries in the file at first, plus exploring the tables (since I was surprised some were empty tables, 16 in this case (see below)).Hence, it might be easier to review by checking each commit one by one instead of understanding the complete diff all at once.
The couple first commits didn't change the resulting database, as the first three find commands were erroring out because of the long deprecated find test
-perm +111
. Once I transformed it to the equivalent-perm /a+x
("any file that has the executable bit set for anybody"), the resulting SQL dump grew from 4.93 MB to 7.27 MB, since more deps were found. The number of empty tables is now 11.There is only one commit that effectively makes a small difference in the results outputted: replacing
find *
withfind ./*
. This makes all the paths for the.a
,.o
, and.so
found withfind
start with./
instead of nothing. I found the difference betweenfind .
andfind *
, but couldn't find the reason why 20 years ago (the furthest I could go back with the grass-legacy repo https://github.com/OSGeo/grass-legacy/blob/66914c9eb661b32031f493845c6694819cd41f89/tools/sql.sh) the author chosefind .
for the first 3, andfind *
for the others.find .
looks for hidden files, whilefind *
looks for visible contents. So I kept the*
.A remaining change that I intentionally left out, is the subshell surrounding the first three finds. I assume it was there since the LD_LIBRARY_PATH was assigned to, so to prevent affecting the current shell. But it has been commented out
The last commit of all is uniformizing the shell formatting with
My couple last shell contributions were made with that too, and some other PR is coming too.
In the end of this PR, I get the following output
Before this PR, I get the following: