Conversation
|
Does this require... ? |
|
No, |
|
Related to #152 |
scripts/lb-wrapper
Outdated
| # adjust above line to also reroute the return code of the underlying command as a line saying "return code: 0" or "return code: 1" or "return code: 2" etc. | ||
| > >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* ]] || [[ $line == "yt_dlp_rc: "* ]]; then echo "$line"; else log "Info" "$line"; fi; done) \ | ||
| 2> >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* ]]; then echo "$line"; else log "Debug" "$line" 1>&2; fi; done; echo "yt_dlp_rc: $?" 1>&2) & |
There was a problem hiding this comment.
I'm trying to understand this.
@deldesir is the following closer to the truth, of what we're trying to accomplish?
| # adjust above line to also reroute the return code of the underlying command as a line saying "return code: 0" or "return code: 1" or "return code: 2" etc. | |
| > >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* ]] || [[ $line == "yt_dlp_rc: "* ]]; then echo "$line"; else log "Info" "$line"; fi; done) \ | |
| 2> >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* ]]; then echo "$line"; else log "Debug" "$line" 1>&2; fi; done; echo "yt_dlp_rc: $?" 1>&2) & | |
| # adjust above line to also reroute the return code of the underlying command as a line saying "xklb_rc: 0" or "xklb_rc: 1" or "xklb_rc: 2" etc. | |
| > >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* || $line == "xklb_rc: "* ]]; then echo "$line"; else log "Info" "$line"; fi; done) \ | |
| 2> >(while read -r line; do if [[ $line == downloading* || $line =~ \[https://.*\]:* ]]; then echo "$line"; else log "Debug" "$line" 1>&2; fi; done; echo "xklb_rc: $?" 1>&2) & |
There was a problem hiding this comment.
I was trying to make lb-wrapper to report underlying yt-dlp return code. We already had $rc for xklb.
There was a problem hiding this comment.
Return code $? on Line 69 is arising from what command exactly?
(This definitely doesn't look like yt-dlp's return code.)
In any case, please clear up what $? is really doing here, and why?
(And how this was tested please if possible!)
There was a problem hiding this comment.
It's the exit status of the last underlying command (yt-dlp) executed by xklb.
There was a problem hiding this comment.
I could see it's yt-dlp because I could reroute its output. This exit status code is not doing anything useful here. It was me debugging yt-dlp and I forgot to remove this code.
There was a problem hiding this comment.
This exit status code is not doing anything useful here. It was me debugging yt-dlp and I forgot to remove this code.
-
Please remove any temporary code and confirm.
-
Please also fix Lines 56, 58 and 60 which contain (former variable) XKLB_EXECUTABLE.
Thanks!
There was a problem hiding this comment.
Temporary code removed.
scripts/lb-wrapper
Outdated
| case $rc in | ||
| 0) | ||
| log "Info" "lb-wrapper's xklb command (${XKLB_INTERNAL_CMD}) completed successfully." | ||
| exit 0 | ||
| ;; | ||
| 1) | ||
| log "Error" "Error $rc occurred while running lb-wrapper's xklb commands." | ||
| exit 1 | ||
| ;; | ||
| *) | ||
| log "Error" "Unknown error occurred while running lb-wrapper's xklb commands. Return code: $rc" | ||
| exit $rc | ||
| ;; | ||
| esac |
There was a problem hiding this comment.
Is a 3-way case statement really necessary?
(What's so special about Return Code 1?)
Can we instead simplify, as follows?
| case $rc in | |
| 0) | |
| log "Info" "lb-wrapper's xklb command (${XKLB_INTERNAL_CMD}) completed successfully." | |
| exit 0 | |
| ;; | |
| 1) | |
| log "Error" "Error $rc occurred while running lb-wrapper's xklb commands." | |
| exit 1 | |
| ;; | |
| *) | |
| log "Error" "Unknown error occurred while running lb-wrapper's xklb commands. Return code: $rc" | |
| exit $rc | |
| ;; | |
| esac | |
| if [ $rc -eq 0 ]; then | |
| log "Info" "lb-wrapper's xklb command (${XKLB_INTERNAL_CMD}) completed successfully." | |
| else | |
| log "Error" "Error $rc occurred while running lb-wrapper's xklb commands." | |
| exit $rc | |
| fi |
There was a problem hiding this comment.
Nothing special. But exit 0 is missing in the if statement. So I suggest:
| case $rc in | |
| 0) | |
| log "Info" "lb-wrapper's xklb command (${XKLB_INTERNAL_CMD}) completed successfully." | |
| exit 0 | |
| ;; | |
| 1) | |
| log "Error" "Error $rc occurred while running lb-wrapper's xklb commands." | |
| exit 1 | |
| ;; | |
| *) | |
| log "Error" "Unknown error occurred while running lb-wrapper's xklb commands. Return code: $rc" | |
| exit $rc | |
| ;; | |
| esac | |
| if [ $rc -eq 0 ]; then | |
| log "Info" "lb-wrapper's xklb command (${XKLB_INTERNAL_CMD}) completed successfully." | |
| else | |
| log "Error" "Error $rc occurred while running lb-wrapper's xklb commands." | |
| exit $rc | |
| fi |
There was a problem hiding this comment.
exit $rc is the same as exit 0 on Line 87, and doesn't do anything useful.
(Programs always exit with return code 0, regardless, when they complete successfully.)
Recap: please remove exit $rc on Line 87, ok?
There was a problem hiding this comment.
Ok. Thanks for clarifying.
|
Looks good, and sorry if that was a bit of a distraction at the bottom of scripts/lb-wrapper ! @deldesir, the key question (above) is what |
|
Done |
|
What testing does this most need? (Should this be tested together with... ?) |
🚀 Pull Request Overview:
With this PR,
lb-wrappercan be used with the search command provided a search term is specified as an argument. For example:This will execute the xklb search command with the provided search term
📋 Checklist:
📌 Testing scenarios:
See Issue #97
cc @EMG70