-
Notifications
You must be signed in to change notification settings - Fork 15
/
dev.sh
29 lines (23 loc) · 617 Bytes
/
dev.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
case "$(basename "$(\ps -p $$ | awk 'NR > 1 { sub(/^-/, "", $4); print $4 }')")" in
zsh) __minidev_source_dir="$(dirname "$0:A")" ;;
bash) __minidev_source_dir="$(builtin cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ;;
*) echo "unsupported shell" >&2 ; return 1 ;;
esac
dev() {
local tmp ret finalizer
tmp="$(mktemp -u)"
exec 9>"${tmp}"
exec 8<"${tmp}"
rm -f "${tmp}"
"${__minidev_source_dir}/bin/dev" "$@"
ret=$?
while read -r finalizer; do
case "${finalizer}" in
chdir:*) cd "${finalizer//chdir:/}" ;;
*) ;;
esac
done <&8
exec 8<&-
exec 9<&-
return ${ret}
}