Closed rpi4iot closed 4 years ago
It seems the ansi sequence impact the regex match
-re 'pi@raspberrypi: ~' works (note: space between : and ~)
pi@raspberrypi:~ $ echo $PS1
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w \$\[\033[00m\]
pi@raspberrypi:~ $
b'\r\n\x1b]0;pi@raspberrypi: ~\x07\x1b[01;32mpi@raspberrypi\x1b[00m:\x1b[01;34m~ $\x1b[00m \r\n\x1b]0;pi@raspberrypi: ~\x07\x1b[01;32mpi@raspberrypi\x1b[00m:\x1b[01;34m~ $\x1b[00m '
You're right. Sometimes $PS1
has parts of it colorized. You need to take that into consideration when writing the regex pattern. Usually I would change PS1 after successful login to make things easier.
expect -re can't match specific character ~ $ cygwin on windows 10