Diff
1diff --git a/plugins/wd/wd.sh b/plugins/wd/wd.sh
2old mode 100644
3new mode 100755
4index 802ed10ee1f14156048b4c22296b2dc01cefbbcd..618995c632f94535f7fd0c59eca346f45041d103
5--- a/plugins/wd/wd.sh
6+++ b/plugins/wd/wd.sh
7@@ -183,6 +183,11 @@ wd_add()
8 then
9 wd_remove $point > /dev/null
10 printf "%q:%s\n" "${point}" "${PWD/#$HOME/~}" >> $WD_CONFIG
11+ if (whence sort >/dev/null); then
12+ local config_tmp=$(mktemp "${TMPDIR:-/tmp}/wd.XXXXXXXXXX")
13+ # use 'cat' below to ensure we respect $WD_CONFIG as a symlink
14+ sort -o "${config_tmp}" $WD_CONFIG && cat "${config_tmp}" > $WD_CONFIG && rm "${config_tmp}"
15+ fi
16
17 wd_export_static_named_directories
18
19@@ -342,8 +347,8 @@ wd_clean() {
20 wd_export_static_named_directories() {
21 if [[ -z $WD_SKIP_EXPORT ]]
22 then
23- grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read warpdir ; do
24- hash -d "$warpdir"
25+ command grep '^[0-9a-zA-Z_-]\+:' "$WD_CONFIG" | sed -e "s,~,$HOME," -e 's/:/=/' | while read warpdir ; do
26+ hash -d "$warpdir"
27 done
28 fi
29 }
30@@ -430,7 +435,10 @@ else
31 break
32 ;;
33 "-r"|"--remove"|"rm")
34- wd_remove $2
35+ # Loop over all arguments after "rm", separated by whitespace
36+ for pointname in "${@:2}" ; do
37+ wd_remove $pointname
38+ done
39 break
40 ;;
41 "-l"|"list")