Community Packages

Please read this before reporting a bug:

Do NOT report bugs when a package is just outdated, or it is in Unsupported. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!

FS#27313 - [pkgtools] pkgfile-hook hooks should not execute when piped or in a subshell

Attached to Project: Community Packages
Opened by Simon Gomizelj (simongmzlj) - Monday, 28 November 2011, 19:53 GMT
Last edited by Jelle van der Waa (jelly) - Saturday, 17 November 2012, 14:53 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Gavin Bisesi (Daenyth)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No



pkgfile-hook.{zsh,bash} should not run when part of a pipe or subshell. The hook's message gets piped around and this can lead to some unexpected behaviour. Better to no do anything. The following snippet is sufficient to check:

local pid ppid pgrp session tty_nr tpgid

# do not run when within a pipe or subshell
[[ ! -t 1 ]] && return 127
read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
[[ $$ -eq $tpgid ]] && return 127

Should work for both bash and zsh.

Additional info:
* pkgtools 23-2

Steps to reproduce:

With a package that you don't have installed (for examples sake, emacs), run:
$ emacs > dump.

Dump will now contain pkgfile-hook's generated message.

$ emacs &

Makes a mess of the terminal.
This task depends upon

Closed by  Jelle van der Waa (jelly)
Saturday, 17 November 2012, 14:53 GMT
Reason for closing:  Won't fix
Additional comments about closing:  This bugreport is reported against the old pkgfile package, the new one is rewritten in C