Browse code

zsh openrc compatibility

Replacing $BASH_SOURCE with ${BASH_SOURCE:-$0} makes devstack zsh friendly: in
bash, $BASH_SOURCE is used per usual; in zsh, where $BASH_SOURCE isn't
defined, $0 is used, which, unlike in bash, evaluates to the current
source file.

Now you can source devstack's openrc from a zsh shell.

Tested with bash and zsh from directories other than the root devstack
directory.

Change-Id: Iab1a817b15d86144163b5094bb58f94b15c598a0

Peter Feiner authored on 2013/10/25 07:51:44
Showing 3 changed files
... ...
@@ -13,7 +13,7 @@ if [[ -n "$2" ]]; then
13 13
 fi
14 14
 
15 15
 # Find the other rc files
16
-RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
16
+RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
17 17
 
18 18
 # Get user configuration
19 19
 source $RC_DIR/openrc
... ...
@@ -18,7 +18,7 @@ if [[ -n "$2" ]]; then
18 18
 fi
19 19
 
20 20
 # Find the other rc files
21
-RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
21
+RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
22 22
 
23 23
 # Import common functions
24 24
 source $RC_DIR/functions
... ...
@@ -1,7 +1,7 @@
1 1
 # stackrc
2 2
 #
3 3
 # Find the other rc files
4
-RC_DIR=$(cd $(dirname "$BASH_SOURCE") && pwd)
4
+RC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
5 5
 
6 6
 # Destination path for installation
7 7
 DEST=/opt/stack