#!/bin/sh
set -euC

# Variables.
prog="$(basename "$0")"
dir="$(dirname "$0")"

# Delegate to executable files in `*.d` directory.
if ! [ -t 1 ]
then
    stdin="$(cat)"
fi
for file in "$dir/${prog}.d/"*
do
    if [ -x "$file" ]
    then
        if ! [ -t 1 ]
        then
            printf "%s\n" "$stdin" | "$file" "$@" || exit "$?"
        else
            "$file" "$@" || exit "$?"
        fi
    fi
done
