#!/bin/sh usage() { printf 'usage: %s [file.lisp]\n' $0 exit 1 } ## The first program finds certain definitions and inserts a new blank ## line *before* the definition. Such action makes function ## definitions separated by two blank lines in some cases. We then ## remove the excess with the second program. Notice we need the -E ## option because we're using the | metacharacter that is only ## supported by popular sed programs with the -E option. This ## violates POSIX sed, but keep in mind that we only run this when ## releasing the package. This is a building tool, not part of the ## service. sed -E '/^\(defun |\(defmacro /{ i\ }' "$@" | sed '/^[ \t]*$/{ N /^[ \t]*\n$/D }' ## We first find a blank line. Then we say N to expand the pattern ## space to include the next line. Then we delete the *first* blank ## line and not the second---that's what the D command does. This ## strategy is explained by Dale Dougherty and Arnold Robbins in ``sed ## & awk'' second edition, pages 112--114.