Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doesn't work command with pipe in zsh #951

Closed
seiyeah78 opened this issue Aug 23, 2019 · 8 comments
Closed

Doesn't work command with pipe in zsh #951

seiyeah78 opened this issue Aug 23, 2019 · 8 comments

Comments

@seiyeah78
Copy link

When use tig command with pipe | in zsh, command stop every time.

$ git log | tig
zsh: done                    git log |
zsh: suspended (tty output)  tig

$ fg
[1]  + done       git log |
       continued  tig
zsh: can't set tty pgrp: operation not permitted

What's the problem?

@koutcher
Copy link
Collaborator

You don't give much information on your configuration but some zsh versions had a regression on pgrp.

@2energycell
Copy link

2energycell commented Oct 10, 2019

I have the similar issue, the command git diff head|tig returns:

[1]  + 1026 done                    git diff head |
          1027 suspended (tty output)  tig

instead of showing what is expected.
I have all the newest: catalina, zsh, ohmyzsh, iterm2, brew, etc;
@jonas please help

@koutcher
Copy link
Collaborator

The problem is linked with calls to setpgid / tcsetpgrp that were introduced by 71e8361.

The command fails with zsh 5.7.1 (x86_64-apple-darwin15.6.0) and zsh 5.6 (x86_64-apple-darwin15.6.0), however it worked well with zsh 5.0.8 (x86_64-apple-darwin15.0) and zsh 5.5.1 (x86_64-apple-darwin15.6.0) and it also works with other shells like ksh, bash.

So the cause is likely to be a regression in zsh introduced between zsh 5.5.1 and 5.6:

2018-04-17  Peter Stephenson  <p.stephenson@samsung.com>

	* 42630: Src/exec.c, Src/signals.c: Improve process group
	handling in pipelines.  Main shell will reclaim terminal if
	leader exits.  Allow SIGCHLD to interrupt reading data from
	command substitution. 

@lwfitzgerald
Copy link

I quick way to install zsh 5.5.1 for those using homebrew:

HOMEBREW_NO_AUTO_UPDATE=1 brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/6d3232544b5f6f0d2b65c6ed89622beb11c4643b/Formula/zsh.rb

Catalina isn't in the formula at this point.

@koutcher
Copy link
Collaborator

koutcher commented Dec 8, 2019

If you don't want to downgrade zsh, the workaround is to use parentheses: git log | (tig).

@seiyeah78
Copy link
Author

@koutcher @lwfitzgerald
Thank you for your reply and suggesting a solution!

@2energycell
I added alias to .zshrc like this.

alias tig=\(tig\)

git diff head | tig means git diff head | (tig) and work correctly.

@nedbat
Copy link

nedbat commented Sep 3, 2020

The parenthesis trick isn't working for me, using zsh 5.8. Any other ideas to make it work?

@EHJ-52n
Copy link

EHJ-52n commented Aug 18, 2024

I have the same problem with zsh, but it's not related to tig:

$ echo 'bXlzZWNyZXRwYXNzd29yZA==' | (base64 -d)
$ echo 'bXlzZWNyZXRwYXNzd29yZA==' |base64 -d
$ echo "$(echo 'bXlzZWNyZXRwYXNzd29yZA==' | base64 -d)"
mysecretpassword
$ apt-cache show zsh | grep -i version
Version: 5.8.1-1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants