home *** CD-ROM | disk | FTP | other *** search
/ Big Green CD 8 / BGCD_8_Dev.iso / NEXTSTEP / Utilities / WindowDepth.bproj / scanprefs.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1997-11-02  |  1.7 KB  |  59 lines

  1. #! /bin/sh
  2. #+++
  3. #  title:    scanprefs
  4. #  abstract:    scan user preferences databases for owners/domains.
  5. #  author:    Tom Hageman <tom@basil.icce.rug.nl>
  6. #  created:    November 1997
  7. #  modified:
  8. #  copyleft:
  9. #
  10. #    Copyright (C) 1997 Tom R. Hageman, but otherwise perfect freeware.
  11. #
  12. #  description:
  13. #    Usage: scanprefs [<NEXTSTEP-key> [<OPENSTEP-key>]]
  14. #    
  15. #    This scans both the NEXTSTEP as the OPENSTEP defaults database.
  16. #    With no arguments, only the owner/domain names are returned.
  17. #    With a single argument, this is searched (and returned) in
  18. #    both NEXTSTEP and OPENSTEP databases.
  19. #    With two arguments, the first is searched (and returned) in the
  20. #    NEXTSTEP database, and the second is searched in the OPENSTEP database.
  21. #
  22. #    NEXTSTEP entries are preceded with `N', and OPENSTEP entries are
  23. #    preceded with `O'.
  24. #
  25. #  bugs:
  26. #    only understands `simple' non-multiline, non-quoted values.
  27. #---
  28.  
  29. PATH=/usr/ucb:/bin:/usr/bin export PATH
  30.  
  31. err=/dev/null
  32. #err=/dev/console
  33.  
  34. case $# in
  35. 0) ;;
  36. 1) NXPref="$1"; NSPref="$NXPref";;
  37. 2) NXPref="$1"; NSPref="$2" ;;
  38. *) echo "Usage: `basename $0` [<NEXTSTEP-key> [<OPENSTEP-key>]]" >&2
  39.    exit 2
  40. esac
  41.  
  42. {
  43.   # Just let it silently fail on pre-OPENSTEP..
  44.   {
  45.     case "$NSPref" in
  46.     ?*) defaults find "$NSPref" | sed "s/.*'\(.*\)': {\(.*\) = \(.*\);.*/\1 \2 \3/"
  47.     esac
  48.     defaults domains | tr ' ' '\012'
  49.   } | sed "s/^/O /"
  50.   {
  51.     case "$NXPref" in
  52.     ?*) dread -n "$NXPref"
  53.     esac
  54.     # This heuristic sed filter removes most of the cruft due to multiline values,
  55.     # as proper multi-line quoted string parsing would be too painful for now.
  56.     dread -l | sed "/^[a-zA-Z0-9]/!d; /^[^ ][^ ]* [^ ][^ ]* [^ ]/!d; s/ .*//"
  57.   } | sed "s/^/N /"
  58. } 2>$err | sort -uf +1 -2 +0 -1 2>$err
  59.