guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cleverness in pre-inst-guile


From: Thien-Thi Nguyen
Subject: Re: Cleverness in pre-inst-guile
Date: Tue, 05 Mar 2002 16:08:41 -0800

[guile-devel cc'ed]

   From: Rob Browning <address@hidden>
   Date: Tue, 05 Mar 2002 10:48:30 -0600

   Could you explain what this is doing?  Something similar looks like it
   might be quite useful for us in gnucash as well.

       # This hair prevents double inclusion.
       # The ":" prevents prefix aliasing.
       case x"$GUILE_LOAD_PATH" in x*${top_srcdir}:*) ;;
         *) GUILE_LOAD_PATH="${top_srcdir}:$GUILE_LOAD_PATH" ;;
       esac

in my (admittedly limited) understanding of bourne shell, `case' is the
only construct that does pattern matching.

here, if top_srcdir is already part of GUILE_LOAD_PATH, we take the
first branch (and don't do anything), otherwise we take the default
branch (GUILE_LOAD_PATH is prefixed w/ top_srcdir).  this might be
easier to understand if the expression is re-written like so:

       case x"$GUILE_LOAD_PATH" in
         x*${top_srcdir}:*) ;;
         *) GUILE_LOAD_PATH="${top_srcdir}:$GUILE_LOAD_PATH" ;;
       esac

the ":" ensures that any matches are "full" matches since ":" is the
element delimiter.  for example, if top_srcdir is "/foo", we don't want
matching to occur if GUILE_LOAD_PATH has "/foo/bar"; we want the end
result to be "/foo:/foo/bar".

thi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]