#!/bin/sh set -eu SELF="${0##*/}" if [ -z "${TMPDIR:-}" ]; then TMPDIR=/tmp fi for i in $LOGNAME volatile; do if [ -d "${TMPDIR}/$i" ]; then TMPDIR="${TMPDIR}/$i" break fi done export TMPDIR TMPDIR=$(mktemp -dp "$TMPDIR" cont.XXXXXXXXXX) cleanup() { cd / && rm -r "$TMPDIR" [ ! -t 0 ] || stty echo trap - 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 } trap cleanup 0 1 2 3 4 5 6 7 8 10 11 12 13 14 15 cd "$TMPDIR" case "$1" in (application/ms-tnef) tnef;; (application/x-zip-compressed) unzip /dev/stdin;; (application/x-7z-compressed) z7 e /dev/stdin;; (application/zip) unzip /dev/stdin;; esac nfiles=$(ls -1 | wc -l) if [ $nfiles -eq 1 ]; then setsid run-mailcap * & PID=$! ZSH_PREFILL_CMD="mv '$(echo -n *)' " x-terminal-emulator perl -e "kill '-TERM', $PID" else ZSH_RUN_ON_LOAD="ls -l" x-terminal-emulator fi