#!/bin/sh set -e editors="" for editor in ed nex nvi vim; do if command -v "$editor" >/dev/null; then if test -z "$editors"; then editors="$editor" else editors="$editors\n$editor" fi fi done random_editor="$(echo "$editors" | shuf | head -n 1)" $random_editor "$@"