~krathalan/wtwitch#5: 
Cannot run wtwitch: "line 452: true: unbound variable"

I get this on a fresh install of the program with all flags.

Starting wtwitch debug log
Package: installed via pacman
Versions: bash-5.0.17(1)-release wtwitch-1.7 jq-1.6 streamlink 1.4.1
Date: Sun 05 Jul 2020 11:30:55 PM EDT

Command: wtwitch -d

Config file:

{
  "player": "mpv",
  "quality": "best",
  "colors": "true",
  "subscriptions": [],
  "apiToken": "",
  "apiTokenExpiry": "1590532419"
}

-----------------------------------------------------------
                         Begin log
-----------------------------------------------------------

+ TITLE_CHARACTERS=11
+ case "${WTWITCH_LANG}" in
+ WTWITCH_LANG=en
+ TITLE_CHARACTERS=18
+ [[ 1590532419 == \n\u\l\l ]]
++ LANG=C
++ date +%s
+ [[ 1594006255 -gt true ]]
/usr/bin/wtwitch: line 452: true: unbound variable

Seems to have to do with the check for expired tokens;

# If the API token is null (e.g. there is no token),
# OR if API token is expired
if [[ "${apiToken}" == "null" ]] || [[ "$(LANG=C date +%s)" -gt "${apiTokenExpiry}" ]]; then
  download_token
fi

Setting apiTokenExpiry to an empty string changes the error to /usr/bin/wtwitch: line 452: mpv: unbound variable, replacing true with mpv.

Status
RESOLVED FIXED
Submitter
~firegem
Assigned to
Submitted
2 years ago
Updated
2 years ago
Labels
bug

~krathalan 2 years ago

Thank you for the great bug report. I was able to replicate the issue when using wtwitch for the first time on a clean chroot without internet.

Info: it seems like this is a combined issue. Your apiToken value got set to "" (empty) when either you were offline or there was a different problem downloading the apiToken. read is used to get user settings. read skips empty values, so the the read command set apiToken to the next non-empty value, which happened to be apiTokenExpiry (1590532419), and apiTokenExpiry got set to the next non-empty value after that, which happened to be useColors (true). This read behavior is also why true was replaced with mpv when you set apiTokenExpiry to an empty string.

~firegem I have pushed an attempted fix to the git master branch. Can you please checkout the master branch and see if your issue is resolved? You shouldn't need to change anything in your config; you should simply:

  • git clone https://git.sr.ht/~krathalan/wtwitch
  • cd wtwitch
  • bash wtwitch [command]

~firegem 2 years ago

Yup, that seems to have fixed it. There was a parse error during the first command, but it failed to show up again, and still gave the expected output anyway. Thanks for the quick fix

~krathalan 2 years ago

Glad to hear :) I have pushed out version 1.7.1 to the AUR with the fix.

~krathalan REPORTED FIXED 2 years ago

Register here or Log in to comment, or comment via email.