OSSP CVS Repository

ossp - Difference in ossp-pkg/rc/rc-sample.pod versions 1.1 and 1.2
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/rc/rc-sample.pod 1.1 -> 1.2

--- rc-sample.pod        2002/01/23 16:39:53     1.1
+++ rc-sample.pod        2002/01/28 16:23:20     1.2
@@ -155,15 +155,120 @@
 
 =head1 USE CASE: Dynamic User Environment (DUE)
 
- ....
+=over 4
 
-#   rc configuration for Dynamic User Environment (DUE)
-Dirs          .:..//
-Name          .duerc
-RequireUmask  022      
-RequireOwner  $USER           
-RequireGroup  %{GROUP}
+=item F<$HOME/.bashrc>
 
- ....
+  cd () {
+      eval `rc --eval --conf=$HOME/.duecf - leave`
+      builtin cd ${1+"$@"} 
+      eval `rc --eval --conf=$HOME/.duecf - enter`
+  }
+
+=item F<$HOME/.duecf>
+
+  Dirs          .:..// # current and all parent dirs
+  Name          .duerc
+  NameGlobal    $HOME/.dueglobal:/etc/dueglobal
+  RequireUmask  022      
+  RequireOwner  %{USER}
+  RequireGroup  %{GROUP}
+  Functions     $HOME/.duefunc
+
+=item F<$HOME/.duefunc>
+
+ #   append (or optionally prepend) one or more directories (optionally
+ #   have to be existing) to a colon-separated path variable. In case a
+ #   directory already exists, it is first removed.
+ #
+ #   Usage:   duePathAdd [-p] [-e] <variable> <dir> [<dir> ...]
+ #   Example: duePathAdd -e PATH /bin /sbin /usr/bin /usr/sbin /usr/ccs/bin
+ #
+ duePathAdd () {
+    _prepend=0
+    _exists=0
+    while [ $# -gt 0 ]; do
+        case $1 in
+            -p ) _prepend=1; shift ;;
+            -e ) _exists=1;  shift ;;
+            *  ) break ;;
+        esac
+    done
+    _var="$1"
+    shift
+    _edit_del=""
+    _edit_add=""
+    for _dir in "$@"; do
+        if [ ".${_exists}" = .1 ] && [ ! -d "${_dir}" ]; then
+            continue
+        fi
+        _edit_del="${_edit_del} -e 's;^${_dir}\$;;' -e 's;^${_dir}:;;'"
+        _edit_del="${_edit_del} -e 's;:${_dir}:;:;' -e 's;:${_dir}\$;;'"
+        if [ ".${_prepend}" = .0 ]; then
+            _edit_add="${_edit_add} -e 's;\$;:${_dir};'"
+        else
+            _edit_add="-e 's;^;${_dir}:;' ${_edit_add}"
+        fi
+    done
+    if [ ".${_edit_del}${_edit_add}" != . ]; then
+        eval "${_var}=\`echo \"\$${_var}\" | sed ${_edit_del} ${_edit_add}\`"
+    fi
+    unset _prepend _exists _var _edit_del _edit_add _dir
+ }
+
+ #
+ #   remove one or more directories from a colon-separated path variable
+ #
+ #   Usage:   duePathDel <variable> <dir> [<dir> ...]
+ #   Example: duePathDel PATH /bin /sbin /usr/bin /usr/sbin /usr/ccs/bin
+ #
+ duePathDel () {
+    _var="$1"
+    shift
+    _edit=""
+    for _dir in "$@"; do
+        _edit="${_edit} -e 's;^${_dir}\$;;' -e 's;^${_dir}:;;'"
+        _edit="${_edit} -e 's;:${_dir}:;:;' -e 's;:${_dir}\$;;'"
+    done
+    eval "${_var}=\`echo \"\$${_var}\" | sed ${_edit}\`"
+    unset _var _edit _dir
+ }
+
+
+=item F</cw/.duerc>
+
+  <event name=enter>
+      duePathAdd PATH            $CWD/bin $CWD/sbin
+      duePathAdd MANPATH         $CWD/man
+      duePathAdd INFOPATH        $CWD/info
+      duePathAdd LD_LIBRARY_PATH $CWD/lib
+  </event>
+  <event name=leave>
+      duePathDel PATH            $CWD/bin $CWD/sbin
+      duePathDel MANPATH         $CWD/man
+      duePathDel INFOPATH        $CWD/info
+      duePathDel LD_LIBRARY_PATH $CWD/lib
+  </event>
+
+=item F<$HOME/.dueglobal>
+  
+  <directory path=/cw>
+      <event name=enter>
+          duePathAdd PATH            /cw/bin /cw/sbin
+          duePathAdd MANPATH         /cw/man
+          duePathAdd INFOPATH        /cw/info
+          duePathAdd LD_LIBRARY_PATH /cw/lib
+      </event>
+      <event name=leave>
+          duePathDel PATH            /cw/bin /cw/sbin
+          duePathDel MANPATH         /cw/man
+          duePathDel INFOPATH        /cw/info
+          duePathDel LD_LIBRARY_PATH /cw/lib
+      </event>
+  </directory>
+  <directory path=/usr/opkg>
+      ...
+  </directory>
 
 =cut
+

CVSTrac 2.0.1