Fix find_desktop_file and minor bug fixes.#11
Open
jastintime wants to merge 1 commit into
Open
Conversation
find_desktop_file_by was previously using > [[ -z "$HOME/.local/share/applications" ]] && This is incorrect, the string in this test will never be empty instead what we want to do is check if the directory does not exist this can be achived with > [[ ! -d "$HOME/..." ]] && https://www.shellcheck.net/wiki/SC2157 protocol is changed from =file to "file" to make it obvious we are setting it to the string not the program https://www.shellcheck.net/wiki/SC2209 > - if [[ -n "$(echo "$w" | grep '^\$')" ]]; then > + if echo "$w" | grep -q '^\$';then we change from [[ -n ]] to grep -q to quit early if we don't match and to make it a bit cleaner. > - program="$(echo "$w" | sed 's/^\$//')" > - app[$i] > + program="${w#\$}" > + app[i] https://www.shellcheck.net/wiki/SC2001 https://www.shellcheck.net/wiki/SC2004 A little less overhead without an external call, also a bit easier to read Remaining changes were simply explictly passing in a function argument and double quoting to prevent globbing.
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.
find_desktop_file_by was previously using
This is incorrect, the string in this test will never be empty instead what we want to do is check if the directory does not exist this can be achived with
https://www.shellcheck.net/wiki/SC2157
protocol is changed from =file to "file" to make it obvious we are setting it to the string not the program
https://www.shellcheck.net/wiki/SC2209
we change from [[ -n ]] to grep -q to quit early if we don't match and to make it a bit cleaner.
A little less overhead without an external call, also a bit easier to read
Remaining changes were simply explictly passing in a function argument and double quoting to prevent globbing.
Note
Shellcheck still complains about https://www.shellcheck.net/wiki/SC2207
Fixing that is probably a good idea.