summaryrefslogtreecommitdiff
path: root/etc/functions/xsource
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-03-14 14:43:49 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2009-03-14 14:43:49 +0100
commitf5444229e95e643c4bc01908081d410f81a29f8c (patch)
treebd5f4e20b28338dae4d859d6013badf5df512f4e /etc/functions/xsource
parent092cef3569b3426f3b5feba9762fe31a911c0049 (diff)
xsource: Added -e option to preserve parameters
Diffstat (limited to 'etc/functions/xsource')
-rwxr-xr-xetc/functions/xsource20
1 files changed, 17 insertions, 3 deletions
diff --git a/etc/functions/xsource b/etc/functions/xsource
index 2546965..50ad5be 100755
--- a/etc/functions/xsource
+++ b/etc/functions/xsource
@@ -1,8 +1,22 @@
## vim:ft=zsh
# Note: This function's behaviour differs hrom source.
# With source, parameters declared local are available to the sourcing script.
-# With xsource, parameters declared local will NOT be available.
-# Keep that in mind when using this function
+# With xsource, parameters declared local will NOT be available unless you use
+# eval $(xsource -e file)
+typeset -i eval=0
+
+while [[ $1 == -* ]] {
+ case $1 in
+ -e) eval=1 ;;
+ esac
+ shift
+}
+
+
if [[ -r $1 ]] {
- source $1
+ if (( eval )) {
+ echo source $1
+ } else {
+ source $1
+ }
}