google/kctf

PS1 set by `activate` doesn't render properly in zsh

gkelly opened this issue · 4 comments

After running source kctf/activate I see:

[*] kCTF environment activated. Run "deactivate" to exit.
[*] To create a cluster config, run "kctf cluster create"
gkelly@pragma> kCTF[ctf=heist$(_kctf_config_string)$(_kctf_chal_string)] > 

Which is my original PS1 (gkelly@pragma> ) with a partially-rendered kCTF status line. I tested this in bash with the same checkout and it works fine.

hmm, that's unexpected since we're also developing with zsh, so I would have assumed that bash would break first :).
Which zsh version are you using? And do you have any special config that might affect the prompt?

I reproduced this using docker and ubuntu:22.04, just apt install zsh and then running zsh then following the local testing instructions led me to the same state.

Here's the Dockerfile:

FROM ubuntu:22.04

RUN apt-get update && \
  DEBIAN_FRONTEND=noninteractive apt-get -y install xxd wget curl netcat zsh

RUN mkdir kctf && \
  curl -sSL https://kctf.dev/sdk | tar xz

ENTRYPOINT /bin/zsh

And then running it and just running source kctf/activate will reproduce:

a665b3a11f6a# source kctf/activate
<snip>
[*] kCTF environment activated. Run "deactivate" to exit.
[*] To create a cluster config, run "kctf cluster create"
a665b3a11f6a# kCTF[ctf=/$(_kctf_config_string)$(_kctf_chal_string)] >

Thank you!
So looks like the way we build the prompt requires:
setopt PROMPT_SUBST

Just setting this option as part of kctf/activate might be an option, but it's also unexpected to the user.
Maybe we can detect the case instead, fall back to not showing the current config/challenge and print a notice to the user.