Skip to content

Commit 9b98186

Browse files
committed
improved detector of $CD in orb vm
In a orb vm, path followed in `/mnt/mac` would be destructed to a host path string (for example `/Users/yourname/Downloads/...`). But this is unexpected behavior when we're testing and calculating `$CD` and `$SCRIPT`.
1 parent 00a1573 commit 9b98186

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

bash.config

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ bump() {
4040
sed -i '' -E -e "s/v$YEAR[0-9]+/$VERSION/g" $f
4141
sed -i '' -E "s/v$((YEAR - 1))[0-9]+/$VERSION/g" $f
4242
done
43-
local src=bash.sh
44-
for f in $CD/bash*; do
45-
if [[ "$(basename $f)" != "$src" ]]; then
46-
fi
47-
done
43+
# local src=bash.sh
44+
# for f in $CD/bash*; do
45+
# if [[ "$(basename $f)" != "$src" ]]; then
46+
# fi
47+
# done
4848
}
4949

5050
bumpold() {

bash.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ bump() {
4040
sed -i '' -E -e "s/v$YEAR[0-9]+/$VERSION/g" $f
4141
sed -i '' -E "s/v$((YEAR - 1))[0-9]+/$VERSION/g" $f
4242
done
43+
# local src=bash.sh
44+
# for f in $CD/bash*; do
45+
# if [[ "$(basename $f)" != "$src" ]]; then
46+
# fi
47+
# done
4348
}
4449

4550
bumpold() {
@@ -1238,9 +1243,12 @@ alias list-all-env-variables=list_all_env_variables list-all-variables=list_all_
12381243
# is_darwin && realpathx() { [[ $1 == /* ]] && echo "$1" || { DIR="${1%/*}" && DIR=$(cd $DIR && pwd -P) && echo "$DIR/$(basename $1)"; }; } || realpathx() { readlink -f $*; }
12391244
in_sourcing && {
12401245
SCRIPT=$(realpathx $(is_zsh_strict && echo "$0" || echo "$BASH_SOURCE")) && CD=$(dirname "$SCRIPT") && debug "$(safety ">> IN SOURCING (DEBUG=$DEBUG), \$0=$0, \$_=$_")"
1241-
} || { SCRIPT=$(realpathx "$0") && CD=$(dirname "$SCRIPT") && debug "$(safety ">> '$SCRIPT' in '$CD', \$0='$0','$1'.")"; }
1246+
} || {
1247+
path_in_orb_host "$0" && SCRIPT="$0" || SCRIPT=$(realpathx "$0")
1248+
CD=$(dirname "$SCRIPT") && debug "$(safety ">> '$SCRIPT' in '$CD', \$0='$0','$1'.")"
1249+
}
12421250
if_vagrant && [ "$SCRIPT" == "/tmp/vagrant-shell" ] && { [ -d "$CD/ops.d" ] || CD=/vagrant/bin; }
1243-
[ -L "$SCRIPT" ] && debug "$(safety "linked script found")" && SCRIPT="$(realpathx "$SCRIPT")" && CD="$(dirname "$SCRIPT")"
1251+
path_in_orb_host "$0" && : || { [ -L "$SCRIPT" ] && debug "$(safety "linked script found")" && SCRIPT="$(realpathx "$SCRIPT")" && CD="$(dirname "$SCRIPT")"; }
12441252
# The better consice way to get baseDir, ie. $CD, is:
12451253
# CD=$(cd `dirname "$0"`;pwd)
12461254
# It will open a sub-shell to print the folder name of the running shell-script.

0 commit comments

Comments
 (0)