Browse code

Escape some metachars that trip up .zdirstore script

Matt Cable authored on 22/04/2010 at 17:26:08
Showing 1 changed files
... ...
@@ -5,8 +5,7 @@
5 5
 # Run dirpersiststore in ~/.zlogout
6 6
 
7 7
 dirpersiststore () {
8
-# FIXME: need to escape all shell metacharacters, not just spaces!
9
-    dirs -p | sed 's/ /\\ /g;s/&/\\&/;s/^/pushd -q /;1!G;h;$!d;' > ~/.zdirstore
8
+    dirs -p | tail -r | perl -ne 'chomp;s/([& ])/\\$1/g ;print "if [ -d $_ ]; then pushd -q $_; fi\n"' > ~/.zdirstore
10 9
 }
11 10
 
12 11
 dirpersistrestore () {