warpdotdev / Warp

Warp is a modern, Rust-based terminal with AI built in so you and your team can build great software, faster.
https://warp.dev
Other
21.11k stars 361 forks source link

[zsh] Global variables leaking from functions #5013

Open xPMo opened 3 months ago

xPMo commented 3 months ago

Dupe Check

Describe the bug

I have setopt warn_create_global set in my .zshrc, because I write plugins for Zsh and I like to check if there are any parameters I'm leaking from my functions accidentally. So I can see that a few of Warp's Zsh integration functions do output warnings from this setting: warp_update_prompt_vars, warp_title, and warp_preexec.

To reproduce

Set setopt warncreateglobal in your .zshrc.

Expected behavior

No exteraneous output.

Screenshots

image

Operating system

Linux

Operating system and version

Arch Linux

Shell Version

zsh 5.9 (x86_64-pc-linux-gnu)

Current Warp version

v0.2024.06.04.08.02.stable_02

Regression

No, this bug or issue has existed throughout my experience using Warp

Recent working Warp date

No response

Additional context

No response

Does this block you from using Warp daily?

No

Is this a Warp specific issue? (i.e. does it happen in Terminal, iTerm, Kitty, etc.)

Yes, this I confirmed this only happens in Warp, not other terminals.

Warp Internal (ignore): linear-label:b9d78064-c89e-4973-b153-5178a31ee54e

None

xPMo commented 3 months ago

Looking at the functions in question, it seems that DISABLE_AUTO_TITLE has no effect, and the other parameters could all be made local. Editing the functions in the running session doesn't cause anything to break.

dannyneira commented 3 months ago

Hi @xPMo Thanks for letting us know. I'm noticing similar behavior in other terminals as well, but not the extra blocks as in your screenshot. As a workaround, disable this just for Warp with the following conditional:

# Bash and Zsh
if [[ $TERM_PROGRAM != "WarpTerminal" ]]; then
# > What you want to disable here <
  setopt warn_create_global
fi

We'll post any updates on this thread.

To anyone else facing this issue, please add a 👍 to the original post at the top or comment with your details, and subscribe if you'd like to be notified.

xPMo commented 3 months ago

Thanks for the response! That's a decent workaround for now. TIL $TERM_PROGRAM is a thing, I guess it's a more common pattern on OSX.

Personally I'm going to leave it as-is to remind myself I can't use the variable $pids because Warp will overwrite it every command in warp_preexec.