diff --git a/plugins/emacs/emacs.plugin.zsh b/plugins/emacs/emacs.plugin.zsh
index 737abe9d6f438c2f5996c4e16594e7d91f5754c5..e22f10740609382779da8060b9ebcd150d41a35f 100644
--- a/plugins/emacs/emacs.plugin.zsh
+++ b/plugins/emacs/emacs.plugin.zsh
@@ -31,13 +31,13 @@ if "$ZSH/tools/require_tool.sh" emacs 23 2>/dev/null ; then
         $EDITOR --eval "$cmd" | tr -d \"
     }
 
-    # display the directory of the file
+    # Write to standard output the directory of the file
     # opened in the the current buffer
     function ecd {
         local cmd="(let ((buf-name (buffer-file-name (window-buffer))))
                      (if buf-name (file-name-directory buf-name)))"
 
-        local dir=`$EDITOR --eval "$cmd" | tr -d \"`
+        local dir="$($EDITOR --eval $cmd | tr -d \")"
         if [ -n "$dir" ] ;then
             echo "$dir"
         else