Ref: https://github.com/Fourdee/DietPi/pull/2099#issuecomment-425925327
>(tee ...)) or STERR (2>&1) must not be redirected when calling patch_file, otherwise tput cannot get cols/lines info and thus G_WHIP windows have wrong dimensions.@Fourdee
Lol, raspi-config found the same issue as above with tput and redirection of STOUT and STERR: https://github.com/asb/raspi-config/blob/master/raspi-config#L11
They solve it with variables that estimate terminal size in the first place.
So yeah we could do:
export TERM_SIZE_X=$(tput cols)
export TERM_SIZE_Y=$(tput lines)
/DietPi/dietpi/patch_file ....redirects
unset TERM_SIZE_X TERM_SIZE_Y
And then make G_WHIP_INIT() use those values, if present instead of trying to re-estimate.
🈯️ Strange, testing exactly the same on my Buster RPi does not has the issue:
2018-10-16 21:27:41 root@micha:/var/log# ( echo $(tput cols) $(tput lines) ) 2>&1 | tee
237 70
🈴 Retest on Stretch VM:
root@VM-Stretch:~# ( echo $(tput cols) $(tput lines) ) 2>&1 | tee
80 24
🈯️ Test on Buster VM:
root@VM-Buster:~# ( echo $(tput cols) $(tput lines) ) 2>&1 | tee
237 71 # One line more than on RPi, as I use a screen caption (fix bottom line) there
🈴 Test on Jessie VM for completeness
root@VM-Jessie:~# ( echo $(tput cols) $(tput lines) ) 2>&1 | tee
80 24
So on tput (ncurses-bin) version from Debian Buster repo (6.1 vs. 6.0) the cols/lines estimation seems to work differently and does not rely on any not redirected output stream. However need fix/workaround!
G_WHIP_INIT(){
WHIP_SIZE_X=$(( ${G_WHIP_SIZE_X_OVERRIDE:-$(tput cols)} - 6 ))
WHIP_SIZE_Y=$(( ${G_WHIP_SIZE_Y_OVERRIDE:-$(tput lines)} - 4 ))
...
}
export G_WHIP_SIZE_X_OVERRIDE=$(tput cols)
export G_WHIP_SIZE_Y_OVERRIDE=$(tput lines)
script/function 2>&1 | tee file.log
unset G_WHIP_SIZE_X_OVERRIDE G_WHIP_SIZE_Y_OVERRIDE
PR up to implement and use within dietpi-update: https://github.com/Fourdee/DietPi/pull/2146
Issue resolved:
dietpi-update from v6.17.4
dietpi-update -1 afterwards
Will mark as closed!
Most helpful comment
@Fourdee
Lol, raspi-config found the same issue as above with tput and redirection of STOUT and STERR: https://github.com/asb/raspi-config/blob/master/raspi-config#L11
They solve it with variables that estimate terminal size in the first place.
So yeah we could do:
And then make G_WHIP_INIT() use those values, if present instead of trying to re-estimate.