Re: [maildropl] backticks: how to put process into background?
Brought to you by:
mrsam
From: Christian E. <bla...@gm...> - 2011-06-20 15:18:03
|
* Sam Varshavchik on Monday, June 20, 2011 at 09:44:05 -0400 > strace explains what's happening. grrh, Mac OS X doesn't provide it. > maildrop's backtick operator captures the output of the > command, and all processes spawned by the backtick operator > write to the same pipe on standard output, so maildrop waits > for the pipe to close, which won't happen until all processes > terminate. > > Adding >/dev/null to the end fixes it. > > import DISPLAY > > `nohup /bin/sh -c "xterm &" >/dev/null` Yey! perfect, thank you. After some shell quote tweaking, my little recipe looks like this: # customize X11 viewer (has to accept stdin) VIEWER="/sw/bin/xv -geometry 100x100 -wait 3 -" # adjust paths of required programs for speed SHELL="/bin/sh" CAT="/bin/cat" AWK="/usr/bin/awk" OPENSSL="/usr/bin/openssl" NOHUP="/usr/bin/nohup" PRINTF="/usr/bin/printf" REFORMAIL="/usr/local/bin/reformail" UNCOMPFACE="/sw/bin/uncompface" # check if $DISPLAY is non-empty if ("$DISPLAY") { if (/^Face:\s+(.{16,})/) { # work around broken headers # (re)create lines of width 79, removing all spaces # delete potentially appended X-Face (Claws-Mail) `$NOHUP $SHELL -c '$PRINTF "%s\n" $MATCH1 | $AWK "{ if (\$1 == \"X-Face:\") exit; OFS = \"\"; \$1 = \$1; line = \$0; do { print substr(line, 0, 79); line = substr(line, 80); } while (length(line)); }" | $OPENSSL base64 -d | $VIEWER &' >/dev/null` } elsif (/^X-Face:\s+(.{16,})/) { # pipe it through uncompface `$NOHUP $SHELL -c '$PRINTF "%s\n" $MATCH1 | $UNCOMPFACE -X | $VIEWER &' >/dev/null` } # remove the header for mutt xfilter "$REFORMAIL -I'Face:' -I'X-Face:'" } to "| $CAT" Can be used in mutt as: set display_filter="maildrop ~/.mailfilters/x-face-filter" Thanks a lot for your help and patience. c -- \black\trash movie _SAME TIME SAME PLACE_ New York, in the summer of 2001 --->> http://www.blacktrash.org/underdogma/stsp.php |