News for hackers. Stuff that matters.
Re:Why I'm Tcl-Ish by prussian on Monday October 26, 2020 @03:42PM (#24900412)
I tend to agree. I am just finishing up a tool I'm using to automate a bunch of interactions I have with the 4 USB UARTs on my desk and I ended up going with expect. If I knew about pexpect I would have probably used that.

However, since I did use expect and spent some time learning Tcl, I actually did appreciate one useful thing about it. It's very easy for me to in-line Tcl code into, say, a configuration, parse it with the help of `[info complete]`, attach it to a list and then expand that list `{*}$some_list` as an argument to `expect` or `interact`. I can now have UART specific macros that are bound to keystrokes like Ctrl-t x. Sure I could do something like that in python, but it probably wouldn't be as clear-cut as:

  # Fix terminal row/col height for less, vi, etc
  # type Ctrl-t r
  bind[r] = {
    # depends on xterm size info, may not be universal
    send "\{ "
    send {old=$(stty -g);}
    send {stty raw -echo min 0 time 5;}
    send {printf '\033[18t' > /dev/tty;}
    send {IFS=';t' read -r _ rows cols _ < /dev/tty;}
    send {stty "$old";}
    send {stty cols "$cols" rows "$rows";}
    send {unset old cols rows;}
    send {shopt -s checkwinsize;}
    send {clear;}
    send " \}\r"
  }
Re:Why I'm Tcl-Ish by kanox on Monday October 26, 2020 @06:01PM (#24902010)
If you want to resize the remote terminal it might be easier to determine the size locally with an ioctl and only execute "stty cols/rows" remotely.

It might also help to export the local TERM value remotely because it's not otherwise passed through a serial port.

Re:Why I'm Tcl-Ish by prussian on Tuesday October 27, 2020 @06:53PM (#24912999)
Thanks to you and the other comment under mine, I revised my snippet. I use to just copy/paste it into screen or tio, but now that I have this tool[1] I don't need to. You're absolutely right I could get the terminal size with tools like resize locally and I probably should set TERM to match.

[1] the tool if anyone is interested: https://gist.github.com/adedomin/7e615405a2275b01dbae3552116...

Re:Why I'm Tcl-Ish by shrubble on Monday October 26, 2020 @08:13PM (#24903153)
In a regular shell, would

eval 'resize'

Do the same thing?