-
-
Notifications
You must be signed in to change notification settings - Fork 784
imgview: handle arguments as strings #1509
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
Conversation
|
@luukvbaal @N-R-K can you please review? |
|
What syntax error are you referring to? Seems like the previous authors specifically call the function with with a empty string, your |
|
The syntax errors displayed on invocation of @0xACE you are right, this short-ciruits the code. Another possible fix is to call |
plugins/imgview
Outdated
| make_thumbs() { | ||
| [ -z "$1" ] && return | ||
| mkdir -p "$NNN_PREVIEWDIR$dir" || return | ||
| if [ "$1" -eq 3 ]; then |
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.
Haven't looked too carefully, but does this work?
| if [ "$1" -eq 3 ]; then | |
| if [ -n "$1" ] && [ "$1" -eq 3 ]; then |
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.
Sure, as long as all other occurrences in the function are guarded, too. How about evaluating the argument as a string and using = or != for comparison?
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 must confess I don't quite remember my thinking when I rewrote this plugin when merging the image plugins. IIRC some of the image programs require thumbnails while others already generate those themselves for certain file types. Looking at this now the arguments passed to make_thumbs() indeed don't seem to make much sense. We are passing 0, 1 3 and "", seems to me we should pass something like 0, 1, 2 and maybe -1 instead of ""? I'm not quite sure how I never ran into that syntax error, I remember thoroughly testing all the options back then.
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.
@luukvbaal thx for your suggestion - -1 makes the intend clear. I'll update the PR shortly. I only came across this because I switched to another image viewer and purged a few others from my system.
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 spelling out the option makes more sense than using magic numbers. It's shell after all :)
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 to just handle arguments as strings and keep the behavior as is.
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.
Any reason not to follow @N-R-K's suggestion? Should not change the behavior either right? Could you check that the commit I pushed works as expected?
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.
Could you check that the commit I pushed works as expected?
Untested, but the change looks good to me.
|
@luukvbaal please approve and merge when ready. |
Avoids the following synax errors: line 34: [: : integer expression expected line 49: [: : integer expression expected
f82fefc to
a4af478
Compare
|
Tested it myself, seems OK. Thanks for bringing up the issue @nblock. |
Exit
make_thumbsearly when invoked with an empty first argument""to avoid a syntax error.