#!/bin/sh
#
# reqshow
#
# $Id: reqshow,v 1.1.1.1 2000/03/06 21:16:11 jwise Exp $
#
# remy@ccs.neu.edu
# 27 June 1994
#
# Copyright (C) 1994 by Remy Evard
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# any later version.
#
# A copy of the license may be found in docs/license of the source
# distribution.
#

active="@{CODE_ACTIVE_DIR}"
resolved="@{CODE_RESOLVED_DIR}"
tmp=/tmp/reqshow.$$

for f in $* ; do
  printed="no"
  while [ "$printed" = "no" ]; do
    if [ -f "$active/$f" ]; then
      if head -1 "$active/$f" | grep -i X-Request-Merged > $tmp ; then
        f=`awk '{print $2}' < $tmp`
      else
        cat $active/$f
        printed="yes"
      fi
    elif [ -f "$resolved/$f" ]; then
      if head -1 "$resolved/$f" | grep -i X-Request-Merged > $tmp ; then
        f=`awk '{print $2}' < $tmp`
      else
        cat $resolved/$f
        printed="yes"
      fi
    else
      echo "unknown request number $f"
      printed="yes"
    fi
  done
done

rm -f $tmp
