From mboxrd@z Thu Jan 1 00:00:00 1970 From: marcus-sup@bar-coded.net (Marcus Williams) Date: Wed, 14 Nov 2007 09:40:23 +0000 Subject: [sup-talk] [PATCH] Pipe message/attachement to shell command In-Reply-To: <1194955037-sup-614@tomsk> References: <1194622205-sup-2949@tomsk> <1194889791-sup-3292@south> <1194905067-sup-4236@tomsk> <1194955037-sup-614@tomsk> Message-ID: <1195032303-sup-7083@tomsk> On 13.11.2007, Marcus Williams wrote: > Mmmm. Seem to be having some buffering problems with open3 on slightly > longer messages. The pipe stuff blocks because of it. > > Will have to resubmit when I figure it out. Ok, heres the new one. I think in the pipe to command case, the session gem is probably the best way to go (although I've not use it here) because it handles the blocking problems for you. This patch will: * return an error correctly if the command returns an error initially (like a usage error, or missing file etc) * pipes the mail/attachment to the command * read either stdout OR stderr, whichever is ready first and display that. The last step is where the problem lies. If a command produces both I cant figure out what to do with it, should it display two separate buffers, one with errors and one with output? What happens if the context of the error is important (ie where it is in the output stream)? I'm pretty sure this is an edge case, as the majority of usages of this would be to pipe through a spam filter, or a file viewer (like textviewer.sh from claws mail or antiword) and this patch works fine in those cases. Anyone any comments? Marcus -------------- next part -------------- A non-text attachment was scrubbed... Name: open3-diffs Type: application/octet-stream Size: 3524 bytes Desc: not available Url : http://rubyforge.org/pipermail/sup-talk/attachments/20071114/5d29ac10/attachment.obj