commit 2b215a8a7b50a869600f308cfbd3df12a33560ff
| author | 斟酌 鵬兄 <tgckpg@gmail.com> |
| date | 2016-04-29T07:34:32Z |
| subject | Detect sourcing |
commit 2b215a8a7b50a869600f308cfbd3df12a33560ff
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date: 2016-04-29T07:34:32Z
Detect sourcing
---
bash/bashrc/rbashrc | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/bash/bashrc/rbashrc b/bash/bashrc/rbashrc
index 3ebb797..3f07008 100644
--- a/bash/bashrc/rbashrc
+++ b/bash/bashrc/rbashrc
@@ -4,7 +4,11 @@ case $- in
*) return;;
esac
-__SCRIPT=$( pwd )/$BASH_SOURCE
+__SCRIPT=$BASH_SOURCE
+echo $BASH_SOURCE | grep -q "^$( pwd )"
+if [ $? -ne 0 ]; then
+ __SCRIPT=$( pwd )/$BASH_SOURCE
+fi
# Source global definitions
if [ -f /etc/bashrc ]; then