--- ssh-agent.el 2004/03/04 10:15:38 1.1 +++ ssh-agent.el 2004/03/04 10:17:06 @@ -21,7 +21,7 @@ ;; Run ssh-agent and ssh-add as emacs processes, setting the proper env ;; variables, and accepting password input -(defcustom ssh-agent-buffer "*ssh-agent*" +(defcustom ssh-agent-buffer " *ssh-agent*" "buffer to display ssh-agent output in" :type 'string :group 'ssh-agent) @@ -51,7 +51,7 @@ :type 'string :group 'ssh-agent) -(defcustom ssh-add-invalid-prompt "Bad passphrase, try again:" +(defcustom ssh-add-invalid-prompt "Bad passphrase, try again for \\([^:]+\\):" "ssh-add prompt indicating an invalid passphrase" :type 'string :group 'ssh-agent) @@ -59,10 +59,28 @@ (defun ssh-agent () "execute the ssh-agent" (interactive) - (let ((args (split-string ssh-agent-args))) - (set-process-filter - (apply #'start-process "ssh-agent" nil ssh-agent-program args) - #'ssh-agent-process-filter))) + (let ((args (split-string ssh-agent-args)) + (sshagent (getenv "SSH_AGENT_PID")) + (sshadd (ssh-noadd-check))) + (cond + ((and sshagent sshadd) + (ssh-add-run)) + ((not sshagent) + (set-process-filter + (apply #'start-process "ssh-agent" nil ssh-agent-program args) + #'ssh-agent-process-filter) + (add-hook 'kill-emacs-hook 'ssh-agent-kill)) + (t + (message "no want."))))) + +(defun ssh-noadd-check () + (with-temp-buffer + (call-process ssh-add-program nil (current-buffer) nil "-l") + (goto-char (point-min)) + (looking-at "^The agent has no identities."))) + +(defun ssh-agent-kill () + (call-process ssh-agent-program nil nil nil "-k")) (defun ssh-add-run () "run ssh-add" @@ -73,9 +91,13 @@ (defun ssh-agent-process-filter (process input) "filter for ssh-agent input" - (cond ((ssh-agent-read-var "SSH_AUTH_SOCK" input) - (ssh-add-run)) - ((ssh-agent-read-var "SSH_AGENT_PID" input)))) + (let ((lines (split-string input "\n"))) + (while lines + (cond ((ssh-agent-read-var "SSH_AUTH_SOCK" (car lines)) + ()) + ((ssh-agent-read-var "SSH_AGENT_PID" (car lines)) + (ssh-add-run))) + (setq lines (cdr lines))))) (defun ssh-agent-read-var (var line) "read a shell script variable from ssh-agent's output" @@ -83,17 +105,21 @@ (with-current-buffer (get-buffer-create ssh-agent-buffer) (let ((value (match-string 1 line))) (setenv var value) - (insert line)) + (insert line "\n")) t))) (defun ssh-add-process-filter (process input) "filter for ssh-add input" + (when (string-match "^\n" input) + (setq input (substring input 1))) (cond ((string-match ssh-add-prompt input) (ssh-send-passwd process input)) ((string-match ssh-add-invalid-prompt input) (ssh-send-passwd process input)) (t (with-current-buffer (get-buffer-create ssh-agent-buffer) - (insert input))))) + (when (string-match "^Identity added:" input) + (message input)) + (insert "\n" input))))) (defun ssh-send-passwd (process prompt) "read a password with `read-passwd` and pass it to the ssh-add process" @@ -102,3 +128,4 @@ (process-send-string process "\n") (clear-string passwd))) +(provide 'ssh-agent)立ち上げた ssh-agent を止めないから、勝手に増殖していたことと、process filter の入力が各ラインでばらばらにくると仮定していたところはちょっとなぁ。。。
こんなことをやっている場合じゃない。
2004/3/2 version 2.59 - Mozilla Firefox 上で M-v が期待通りに動かない問題を解消。とのこと。ちょっと動きが変かもしれない。
修理のあがったデジカメ(7500円なり)、女房のちょっと古いノートパソコンを現役に復帰させるための PC133 S.O.DIMM 512MByte 一枚(30000円ちょっとなり)、エプソンのインクジェットプリンタのインク一式+黒の予備(8000円ぐらいなり)。
あとは、カメラをちょっとだけぼーーと見て心を癒していた。
43,321,963 Jun 11 1999 eijirou.sdic 133,975,920 Sep 19 2001 eijirou.sdic.ary 35,184,988 Jul 22 1999 waeijirou.sdic 117,356,164 Sep 19 2001 waeijirou.sdic.ary 1,184,355 Jan 26 1999 ryakujiro.sdic 3,930,196 Apr 26 2002 ryakujiro.sdic.ary % wc eijirou.sdic 700970 2417225 43321963 eijirou.sdic % wc waeijirou.sdic 738249 2845777 35184988 waeijirou.sdic % wc ryakujiro.sdic 15557 54410 1184355 ryakujiro.sdicどうやら、mkary は 4年前にやり直しているようだ。こいつが、今は
116,164,558 Mar 4 22:12 eijirou.sdic 352,146,864 Mar 4 22:34 eijirou.sdic.ary 92,896,490 Mar 4 22:17 waeijirou.sdic 294,070,372 Mar 4 22:48 waeijirou.sdic.ary 3,148,318 Mar 4 22:14 ryakujiro.sdic 9,888,856 Mar 4 22:44 ryakujiro.sdic.ary % wc eijirou.sdic 1536277 6401098 116164558 eijirou.sdic % wc waeijirou.sdic 1520216 5933400 92896490 waeijirou.sdic % wc ryakujiro.sdic 28826 149369 3148318 ryakujiro.sdicに増えている。すげ。
% ls -la 合計 16 drwxr-xr-x 2 hoge fuga 181 03-04 10:03 . drwxr-xr-x 11 hoge fuga 2161 03-04 09:29 .. -rw-r--r-- 1 hoge fuga 0 03-04 10:02 zzz.txt % mkfile 100k 100k.txt % ls -la 合計 120 drwxr-xr-x 2 hoge fuga 246 03-04 10:03 . drwxr-xr-x 11 hoge fuga 2161 03-04 09:29 .. -rw------- 1 hoge fuga 102400 03-04 10:03 100k.txt -rw-r--r-- 1 hoge fuga 0 03-04 10:02 zzz.txt % mkfile 1000m 1g.txt % ls -la 合計 1024120 drwxr-xr-x 2 hoge fuga 373 03-04 10:04 . drwxr-xr-x 11 hoge fuga 2161 03-04 09:29 .. -rw------- 1 hoge fuga 102400 03-04 10:03 100k.txt -rw------- 1 hoge fuga 1048576000 03-04 10:04 1g.txt -rw-r--r-- 1 hoge fuga 0 03-04 10:02 zzz.txtSolaris では、ずっと昔の GNU ls (textutil だっけ?)を使っていたので載せ替え。ついでに Zaurus も丸山さんちの coreutiles 一式導入。うーーん long-iso の方が良いかなぁと思いつつ、Zaurus だと横幅稼ぎたいなぁ、だけど各マシンで表示形式変わるのもいやだなぁということで、
setenv TIME_STYLE iso導入。dired もすっきり。
(setq ls-lisp-use-insert-directory-program t)してみた。特に問題なさそうかな。