Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: precmd: write error: interrupted



On Apr 25,  7:44pm, Yuri D'Elia wrote:
}
} On 04/25/2013 06:47 PM, Yuri D'Elia wrote:
} > 2) Why "precmd() { { print "HELLO" } >&- 2>&-; } doesn't suppress the
} > error in this case?
} 
} Closest analogue I could find is:
} 
} % { { print >&2 } 2>&- } 2>/dev/null
} zsh: write error

Of course what's happening here is in outside-in order.  Starting with
the stuff you can mostly see:

1. stderr is redirected to /dev/null (old stderr is saved)
2. stderr is closed (at this point the outer redirection is gone)
3. print generates an error

Now the stuff you can't see happens:

4. zsh gets another error writing to the closed stderr
5. zsh warns about that to the saved stderr from step 1

You avoid the whole mess if you never close stderr, or if you close it
before step 1 (e.g. by "exec 2>&-"), though the latter is impractical
in the case we're discussing.



Messages sorted by: Reverse Date, Date, Thread, Author