#!/bin/sh

#   Jan 20/98 - D. Liu (remove ccc in front of xsave to allow better
#                       interactive use of xsaveup) 
#   OCT 09/97 - D. Liu

#id xsaveup - xsave fields provided in the argument list

#   AUTHOR  - D. Liu

#hd PURPOSE - Xsaveup is a script that is essentially a loop for
#hd           xsave. It is named after the program joinup because its
#hd           function is very similar to joinup: it joins up fields
#hd           and saves them with super labels in a file. Unlike
#hd           joinup, there is no upper limit to the number of fields
#hd           one can save with one call to xsaveup.
#hd
#hd           NOTE: Xsaveup inherits features and requirements from xsave: 
#hd                 it requires input card for every field to be saved 
#hd                 just as xsave does; the output file can either have 
#hd                 content or be empty before xsaveup is used.

#pr PARAMETERS:
#pr
#pr   POSITIONAL
#pr
#pr     output  = output file
#pr
#pr     f1...fn = fields to be xsaved

#ex EXAMPLE:
#ex 
#ex      xsaveup new_gp field1 field2 field3
#ex 
#ex   In the above example, xsaveup saves field1, field2, and
#ex   field3 one by one to the output file new_gp. Three separate
#ex   input card sets are required for this operation, that's one
#ex   for each of the three "xsave" calls.
#ex 
#ex      xsaveup new_gp field1
#ex 
#ex   In this example, only one field is saved to the output
#ex   file new_gp.
#ex 
#ex   In summary, the general usage of xsaveup is
#ex 
#ex      xsaveup output field1 [field2 ...]
#ex 


set -e

if [ $# -lt 2 ]; then echo "too few arguments."; exit -1; fi
output=$1

while [ $# -gt 1 ]
do
    shift
    xsave $output $1  new.
    mv    new.    $output
done
