#!/usr/bin/tclsh
########################################################################
#
# Edit some stuff into manual pages.
# 
########################################################################

foreach {infile VERSION DOCDIR M1SUFFIX MnSUFFIX} $argv break

set outfile [file root $infile].mfixed

## prepare text for "SEE ALSO" section
set seealso {}
foreach man [glob man/*.man] {
  if {"$infile"=="$man"} continue
  if {[string match *_* $man]} {
    set section $MnSUFFIX
  } else {
    set section $M1SUFFIX
  }
  lappend seealso "[file tail [file root $man]]($section)"
}
set seealso [join $seealso ", "]

## Now edit $infile into $outfile
exec tclsh ./trivsed -i $infile -o $outfile \
    {\|Version\|} $VERSION \
    {\|Example\|} [file join $DOCDIR example] \
    {\|SEEALSO\|} $seealso


########################################################################
## Local Variables: ##
## mode:tcl ##
## End: ##
