After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 724982 - Zsh should not print VTE escape sequences during cd when stdout is not terminal
Zsh should not print VTE escape sequences during cd when stdout is not terminal
Status: RESOLVED FIXED
Product: vte
Classification: Core
Component: general
0.35.x
Other Linux
: Normal normal
: ---
Assigned To: VTE Maintainers
VTE Maintainers
[fixed-0-36][needed-next][commit:e102...
Depends on:
Blocks:
 
 
Reported: 2014-02-22 23:10 UTC by Michal Sojka
Modified: 2014-03-27 18:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch (885 bytes, patch)
2014-02-22 23:11 UTC, Michal Sojka
none Details | Review
Patch that changes zsh hook used to print VTE escape sequence (1.05 KB, patch)
2014-02-23 23:46 UTC, Michal Sojka
committed Details | Review

Description Michal Sojka 2014-02-22 23:10:28 UTC
Reason: it breaks scripts / commands.

How to reproduce:
zsh
(cd)|hexdump -C

Attached patch fixes the problem for me.
Comment 1 Michal Sojka 2014-02-22 23:11:07 UTC
Created attachment 270019 [details] [review]
Patch
Comment 2 Christian Persch 2014-02-22 23:46:09 UTC
I don't think the patch is right. The vte.sh script already is only doing anything for interactive shells:

# Not an interactive shell?
[[ $- == *i* ]] || return 0

This works for bash; possibly it needs some other test to work in zsh ?
Comment 3 Egmont Koblinger 2014-02-23 03:22:28 UTC
According to http://zsh.sourceforge.net/Guide/zshguide02.html , zsh's way is
[[ -o interactive ]]
Comment 4 Egmont Koblinger 2014-02-23 03:30:04 UTC
Oh, sorry, according to http://zsh.sourceforge.net/Doc/Release/Parameters.html#Parameters-Set-By-The-Shell , $- also works.
Comment 5 Michal Sojka 2014-02-23 10:31:19 UTC
(In reply to comment #2)
> I don't think the patch is right. The vte.sh script already is only doing
> anything for interactive shells:
> 
> # Not an interactive shell?
> [[ $- == *i* ]] || return 0

This does not help. If you run a command in a subshell of an interactive
shell, e.g. you run interactively "(cd)", the interactive flag is still
set in the subshell. Morover vte.sh is not evaluated in this case at all.

The difference between bash and zsh is that for zsh we hook into cd
command, whereas for bash we print the escape sequence as a part of the
prompt. Therefore under bash, "(cd)" itself does not print anything.

Maybe, correct thing for zsh would be to hook into prompt expansion,
similarly as it is done in bash. Current hooking into cd has another
drawback. Consider the following sequence of commands:

# In gnome-terminal
zsh
cd             # Change to $HOME
(cd /tmp)      # Change to /tmp in subshell
# We're still in $HOME

# Open new tab in gnome-terminal - this opens in /tmp instead of at
# $HOME

Thanks,
-Michal
Comment 6 Egmont Koblinger 2014-02-23 10:41:47 UTC
(In reply to comment #5)

> This does not help. If you run a command in a subshell of an interactive
> shell, e.g. you run interactively "(cd)", the interactive flag is still
> set in the subshell.

But then "test -t 1" wouldn't work either, would it? This also evaluates to true in a subshell.

> Maybe, correct thing for zsh would be to hook into prompt expansion,
> similarly as it is done in bash.

Sounds the right thing for me to do.
Comment 7 Michal Sojka 2014-02-23 23:44:46 UTC
(In reply to comment #6)
> (In reply to comment #5)
> 
> > This does not help. If you run a command in a subshell of an interactive
> > shell, e.g. you run interactively "(cd)", the interactive flag is still
> > set in the subshell.
> 
> But then "test -t 1" wouldn't work either, would it? This also evaluates to
> true in a subshell.

Yes, but my original problem was that the output of a command redirected to a file contained some garbage (i.e. VTE escape sequence). Calling test -t helped in this case.

> > Maybe, correct thing for zsh would be to hook into prompt expansion,
> > similarly as it is done in bash.
> 
> Sounds the right thing for me to do.

I'm attaching an updated patch.
Comment 8 Michal Sojka 2014-02-23 23:46:19 UTC
Created attachment 270081 [details] [review]
Patch that changes zsh hook used to print VTE escape sequence
Comment 9 Egmont Koblinger 2014-03-03 10:55:48 UTC
Fixed in vte-0-36. Keeping open for vte-next.
Comment 10 Egmont Koblinger 2014-03-03 10:56:57 UTC
Thanks Michal, it was a nice catch! :)
Comment 11 Christian Persch 2014-03-27 18:16:39 UTC
Fixed on master.