#!/bin/bash # Last edited on 2003-09-10 20:49:13 by stolfi cmd="${0##*/}" usage="${cmd} DIR" # Writes the standard input to a file named "${DIR}/${FILENO}" where # the environment variable {FILENO} must be set by the caller. # Meant to be used as the "-s" argument of formail. if [ $# -ne 1 ]; then echo "usage: ${usage}" 1>&2; exit 1 fi dir="$1"; shift; if [ ! -d ${dir} ]; then echo "${dir} not found or not a directory" 1>&2; exit 1 fi name="${dir}/${FILENO}" seq=0 while [ -r ${name}-${seq} ]; do seq=$((seq + 1)) done echo "-> ${name}-${seq}" 1>&2 cat > "${name}-${seq}"