#!/bin/sh
#
# rnda - choose a random argument using rndi(1d)
# dependencies: rndi

# check we have at least one argument
if [ "$#" -eq 0 ]; then
  printf >&2 'rnda: No args given\n'
  exit 2
fi

# get a random integer from 1 to the number of arguments
argi=$(rndi 1 "$#") || exit

# shift until that argument is the first argument
shift "$((argi - 1))"

# print it
printf '%s\n' "$1"
