chiark / gitweb /
dot/profile: Add a new function to export a variable only if it's defined.
[profile] / dot / profile
index 9617a8fc75ce6290ea8e0c3d8aaa1235581b1377..2d597bf5bf50019bbdcc633f67e12b0744146a87 100644 (file)
@@ -27,7 +27,6 @@ __mdw_addto () {
     case "$new:" in *:$i:*) continue;; esac
     if ! [ -d $i ]; then continue; fi
     case "$val" in
-      "") val=$i change=t; continue ;;
       $i) continue ;;
       *:$i:*) val=${val%%:$i:*}:${val#*:$i:} ;;
       $i:*) val=${val#$i:} ;;
@@ -36,8 +35,8 @@ __mdw_addto () {
     new=$new:$i change=t
   done
   case $dir in
-    l) val=${new#:}:$val ;;
-    r) val=$val$new ;;
+    l) val=${new#:}${val:+:$val} ;;
+    r) val=${val:+$val:}${new#:} ;;
   esac
   case $change in t) eval $var=\$val ;; esac
 }
@@ -58,6 +57,17 @@ __mdw_setconf () {
   fi
 }
 
+## __mdw_export_if_defined VAR ...
+##
+## If VARs are defined, then export them.
+__mdw_export_if_defined () {
+  local var t
+  for var in "$@"; do
+    eval t=\${$var+t}
+    case $t in t) export $var ;; esac
+  done
+}
+
 ###--------------------------------------------------------------------------
 ### Other preliminaries.
 
@@ -282,6 +292,10 @@ CARGO_HOME=$HOME/.cache/cargo; export CARGO_HOME
 ## Configure `ps'.
 PS_PERSONALITY=gnu; export PS_PERSONALITY
 
+## Configure Debian building.
+DEB_BUILD_OPTIONS="parallel=$(mdw-conf make-parallel 4)"
+export DEB_BUILD_OPTIONS
+
 ## Turn off angry fruit salad error messages from things.
 DPKG_COLORS=never; export DPKG_COLORS
 GCC_COLORS=; export GCC_COLORS