home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / conf / mkconfig.csh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-07-09  |  2.3 KB  |  108 lines

  1. #!/bin/csh -f
  2. # Mach Operating System
  3. # Copyright (c) 1992 Carnegie Mellon University
  4. # All Rights Reserved.
  5. # Permission to use, copy, modify and distribute this software and its
  6. # documentation is hereby granted, provided that both the copyright
  7. # notice and this permission notice appear in all copies of the
  8. # software, derivative works or modified versions, and any portions
  9. # thereof, and that both notices appear in supporting documentation.
  10. # CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  11. # CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  12. # ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  13. # Carnegie Mellon requests users of this software to return to
  14. #  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  15. #  School of Computer Science
  16. #  Carnegie Mellon University
  17. #  Pittsburgh PA 15213-3890
  18. # any improvements or extensions that they make and grant Carnegie Mellon 
  19. # the rights to redistribute these changes.
  20. #
  21. #
  22. # HISTORY
  23. # $Log:    mkconfig.csh,v $
  24. # Revision 2.2  92/07/08  16:28:39  mrt
  25. #     Redid script into separate sed call so it would work with the
  26. #     CMU-BSD 4.3 sed and the gnu-sed.
  27. #     [92/07/08            mrt]
  28. # Revision 2.1  92/04/21  17:11:50  rwd
  29. # BSDSS
  30. #
  31. #
  32.  
  33. set CONFIG="${argv[1]}"
  34.  
  35. shift argv
  36.  
  37. (\
  38. sed -n \
  39.     -e "/^[^#]/d" \
  40.     -e 's;    ; ;g' \
  41.     -e "s;^# *\([^ ]*\)[ ]*=[ ]*\[\(.*\)\].*;\1#\2;p" ${argv}\
  42. ;\
  43. echo +${CONFIG} | \
  44. sed  -n -e "s;[-+];#&;gp"\
  45. ;\
  46. sed -n \
  47.     -e '/^#/d' \
  48.     -e '/^$/d' \
  49.     -e 's;^\([^#]*\).*#[     ]*<\(.*\)>[     ]*$;SKIPIT\2#\1;' \
  50.     -e "/^SKIPIT/\!s;\([^#]*\).*;#\1;" \
  51.     -e 's;^SKIPIT;;' \
  52.     -e 's;[     ]*$;;' \
  53.     -e 's;^\!\(.*\);\1#\!;' \
  54.     -e p ${argv}\
  55. ) | \
  56. awk '-F#' '\
  57. part == 0 && $1 != "" {\
  58.     m[$1]=m[$1] " " $2;\
  59.     next;\
  60. }\
  61. part == 0 && $1 == "" {\
  62.     for (i=NF;i>1;i--){\
  63.     s=substr($i,2);\
  64.     c[++na]=substr($i,1,1);\
  65.     a[na]=s;\
  66.     }\
  67.     while (na > 0){\
  68.     s=a[na];\
  69.     d=c[na--];\
  70.     if (m[s] == "") {\
  71.         f[s]=d;\
  72.     } else {\
  73.         nx=split(m[s],x," ");\
  74.         for (j=nx;j>0;j--) {\
  75.         z=x[j];\
  76.         a[++na]=z;\
  77.         c[na]=d;\
  78.         }\
  79.     }\
  80.     }\
  81.     part=1;\
  82.     next;\
  83. }\
  84. part != 0 {\
  85.     if ($1 != "") {\
  86.     n=split($1,x,",");\
  87.     ok=0;\
  88.     for (i=1;i<=n;i++) {\
  89.         if (f[x[i]] == "+") {\
  90.         ok=1;\
  91.         }\
  92.     }\
  93.     if (NF > 2 && ok == 0 || NF <= 2 && ok != 0) {\
  94.         print $2; \
  95.     }\
  96.     } else { \
  97.     print $2; \
  98.     }\
  99. }'
  100.