#!/bin/sh
# $Header: /cvsroot/sadm/cfm-1/bin/idd,v 1.2 2000/05/31 14:49:37 dmetz Exp $
# $crtd:  by  Derald Metzger  on  23feb93 $
# $cmnt:  idd cmd, echo extended env info to stdout
#                Copyright (c) 1998 1999  Derald Metzger
# This file is part of the cfm package (GPL).
# $

osv=`uname`-`uname -r | cut -c1`

case $osv in
  SunOS-4) 
    ppid=`ps -l$$ | grep -v PPID  | cut -c21-24`
    ushell=`ps | grep $ppid | grep -v grep | cut -c21-40`
    echo=/usr/5bin/echo
  ;;
  unicos*|SunOS-5)
    echo=/usr/bin/echo
#   # this is portable. sun's sh has no symbol for its parent
    ppid=`expr "\`ps -lp$$ | grep -v PPID\`" : ' *[0-9]* [A-Z] *[0-9]* *[0-9]* *\([0-9]*\).*'`
    ushell=`expr "\`ps | grep $ppid\`" : '.*[0-9]*:[0-9]* \([-a-z]*\)'`
  ;;
  IRIX*)
    echo=/sbin/echo
    uid=`expr "\`id\`" : 'uid=\([1-9]*\).*'`
    ppid=`ps -l|grep "$uid  $$"|cut -c20-23`
    ushell=`ps|grep $ppid|grep -v grep|cut -d: -f2|cut -d' ' -f2`
  ;;
  Linux*)
    echo="/bin/echo -e"
    ushell=`expr "\`ps|grep $PPID\`" : '.* \([a-z.-]*\)$'`
  ;;
esac
host=`uname  -n | cut -d. -f1`

$echo "## idd:
   host=$host \tTERM=$TERM \tDISPLAY=${DISPLAY:-none}\tshell=$ushell
   USER=$USER      \tLOGNAME=$LOGNAME \tumask=`umask`
   `id`
   PWD=`pwd` \t\tHOME=$HOME
   PATH=$PATH"
