DietPi-Update | Wrong whiptail dimensions when calling G_WHIP in patch_file

Created on 3 Oct 2018  ·  3Comments  ·  Source: MichaIng/DietPi

Ref: https://github.com/Fourdee/DietPi/pull/2099#issuecomment-425925327

  • Either STOUT (>(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.
Beta Debian Jessie Debian Stretch Solution available Visual

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:

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.

All 3 comments

@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!

  • We can't use the G_WHIP_INIT() internal variables, since they need to be reset after every G_WHIP* execution to allow rechecking terminal size, e.g. in case user resizes PuTTY window while script runs.
  • To have complete log files, including errors, as well as terminal output, we need to redirect both steams, no other chance I am aware of.
  • So only solution I am aware of are new exported variables:
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
    G_WHIP issue
  • dietpi-update -1 afterwards
    patch_fix

Will mark as closed!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fourdee picture Fourdee  ·  86Comments

Fourdee picture Fourdee  ·  64Comments

Invictaz picture Invictaz  ·  58Comments

dsnyder0pc picture dsnyder0pc  ·  57Comments

Fourdee picture Fourdee  ·  127Comments