Skip to content

Commit 9e4b91b

Browse files
committed
[zsh] use sh trap to ensure popd always happens
1 parent b82a8d0 commit 9e4b91b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

zsh/.config/zsh/functions

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ q() {
9090

9191
m() {
9292
r >/dev/null
93+
94+
trap popd>/dev/null 1 2 3 6
95+
9396
if [ ! -d .mscripts ]; then
94-
popd >/dev/null
9597
echo "Unable to find .mscripts" && return 1
9698
fi
9799
script="$1"
@@ -100,22 +102,21 @@ m() {
100102

101103
if [ -z "$mscript" ]; then
102104
echo "No mscript avaialble for $script"
103-
popd >/dev/null
104105
return 1
105106
fi
106107

107108
eval .mscripts/"$mscript" $*
108-
popd >/dev/null
109109
}
110110

111111
mm() {
112112
r >/dev/null
113+
trap popd>/dev/null 1 2 3 6
114+
113115
if [ ! -f .mscripts/default ]; then
114116
echo "Unable to find default mscript" && return 1
115117
fi
116118

117119
.mscripts/default "$@"
118-
popd >/dev/null
119120
}
120121

121122
# python venv setup (need to be function as we have to source)

0 commit comments

Comments
 (0)