Subject: bug#8311: 24.0.50; [PATCH] eshell-eval-using-options duplicate symbols

From: Leo <[email-masked]>
Date: Tue, 22 Mar 2011 02:08:17 +0800

The macro expansion of eshell-eval-using-options in eshell/ln looks like
this:

(let
    ((temp-args args))
  (let
      (eshell-option-stub symbolic em-interactive force em-preview em-verbose eshell-option-stub eshell-option-stub eshell-option-stub eshell-option-stub eshell-option-stub eshell-option-stub usage-msg last-value ext-command args)
    (eshell-do-opt "ln"
                   '((104 "help" nil nil "show this usage screen")
                     (115 "symbolic" nil symbolic "make symbolic links instead of hard links")
                     (105 "interactive" nil em-interactive "request confirmation if target already exists")
                     (102 "force" nil force "remove existing destinations, never prompt")
                     (110 "preview" nil em-preview "don't change anything on disk")
                     (118 "verbose" nil em-verbose "explain what is being done")
                     :preserve-args :external "ln" :show-usage :usage "[OPTION]... TARGET [LINK_NAME]\n   or:  ln [OPTION]... TARGET... DIRECTORY\nCreate a link to the specified TARGET with optional LINK_NAME.  If there is\nmore than one TARGET, the last argument must be a directory;  create links\nin DIRECTORY to each TARGET.  Create hard links by default, symbolic links\nwith '--symbolic'.  When creating hard links, each TARGET must exist.")
                   '((let
                         ((no-dereference t))
                       (eshell-mvcpln-template "ln" "linking"
                                               (if symbolic 'make-symbolic-link 'add-name-to-file)
                                               eshell-ln-interactive-query eshell-ln-overwrite-files))))))

The second let has quite a few duplicate symbols. Anybody seeing any
problem with the following patch:

=== modified file 'lisp/eshell/esh-opt.el'
--- lisp/eshell/esh-opt.el	2011-03-21 06:42:23 +0000
+++ lisp/eshell/esh-opt.el	2011-03-21 18:04:57 +0000
@@ -102,11 +102,12 @@
 	       macro-args
 	     (list 'eshell-stringify-list
 		   (list 'eshell-flatten-list macro-args)))))
-     (let ,(append (mapcar (lambda (opt)
-			     (or (and (listp opt) (nth 3 opt))
-				 'eshell-option-stub))
-			   (cadr options))
-		   '(usage-msg last-value ext-command args))
+     (let ,(delete-dups
+	    (append (mapcar (lambda (opt)
+			      (or (and (listp opt) (nth 3 opt))
+				  'eshell-option-stub))
+			    (cadr options))
+		    '(usage-msg last-value ext-command args)))
        (eshell-do-opt ,name ,options (quote ,body-forms)))))
 
 ;;; Internal Functions: