~mdw
/
profile
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4c085f9
)
dot/profile: Add a new function to export a variable only if it's defined.
author
Mark Wooding
<mdw@distorted.org.uk>
Sat, 30 May 2020 12:10:32 +0000
(13:10 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sat, 30 May 2020 12:21:33 +0000
(13:21 +0100)
This is useful for pathish variables: if they're exported then they're
set to empty, which implies the current directory.
dot/profile
patch
|
blob
|
blame
|
history
diff --git
a/dot/profile
b/dot/profile
index
6730a25
..
2d597bf
100644
(file)
--- a/
dot/profile
+++ b/
dot/profile
@@
-57,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.