#! /bin/bash
# Last edited on 2024-03-30 11:27:58 by stolfi

usage="$0 DIRECTORY.."

# Prints the names of the given directories and the contents of the 
# respective 00-README or 00-LEIAME files in them

dirs=( $* )

for d in "${dirs[@]}" ; do
  echo $d 1>&2
  echo " " 1>&2
  rdm="NONE"
  for f in 00-README 00-LEIAME README LEIAME README.md ; do 
    tfile="$d/$f"
    if [[ -s ${tfile} ]]; then
      rdm="${tfile}"; break
    fi
  done
  if [[ "/$rdm" == "/NONE" ]]; then
    echo "(no README)" 1>&2
  else
    cat ${rdm} | head -10 | sed -e '/[Ll]ast edited/d' -e 's:^:  :' 1>&2
  fi
  echo " " 1>&2
done
