comparison lisp/net/tramp.el @ 51177:6234a4fe96f9

Version 2.0.34 (of Tramp) released. (tramp-handle-file-symlink-p): If target of symlink is absolute, return a Tramp filename. (Ie, return "/user@host:/target" instead of "/target".) (tramp-handle-file-truename): Deal with new return value from `file-symlink-p'. (tramp-handle-expand-file-name): Make default method explicit in file name. (tramp-unified-filenames): Move to an earlier spot in the file. (top-level): If tramp-unified-filenames is set and we're running on XEmacs, load tramp-efs. (tramp-wait-for-shell-prompt, tramp-barf-if-no-shell-prompt): New functions, used by tramp-send-command-internal. (tramp-open-connection-setup-interactive-shell): Simplify using `tramp-send-command-internal'. (tramp-send-command-internal): New function. (tramp-methods): New entries "remsh" and "remcp" are like "rsh" and "rcp" but invoke "remsh" instead of "rsh". This is useful on Cray systems, for instance. Unify tramp-rsh-program, tramp-telnet-program, tramp-su-program into tramp-login-program. Likewise with tramp-login-args, tramp-copy-program, tramp-copy-args, tramp-copy-keep-date-arg. Users changed. New method plink1; like plink but pass "-1" to force protocol version 1. (tramp-default-method): Use plink as the default on machines where the plink program is present. (tramp-completion-file-name-handler): Add safe-magic property. (tramp-shell-prompt-pattern): Allow ANSI escapes at end of prompt. (ANSI escapes elsewhere in the prompt are recognized properly already.)
author Kai Großjohann <kgrossjo@eu.uu.net>
date Sat, 24 May 2003 14:10:15 +0000
parents 5b6aaf393205
children 978e262c8f3a
comparison
equal deleted inserted replaced
51176:4ac4c9dab97f 51177:6234a4fe96f9
85 "Implementation of `uuencode' in Lisp.") 85 "Implementation of `uuencode' in Lisp.")
86 86
87 (unless (fboundp 'uudecode-decode-region) 87 (unless (fboundp 'uudecode-decode-region)
88 (autoload 'uudecode-decode-region "uudecode")) 88 (autoload 'uudecode-decode-region "uudecode"))
89 89
90 ;; ;; It does not work to load EFS after loading TRAMP.
91 ;; (when (fboundp 'efs-file-handler-function)
92 ;; (require 'efs))
93
94 ;; Load foreign methods. Because they do require Tramp internally, this
95 ;; must be done with the `eval-after-load' trick.
96
97 ;; tramp-ftp supports Ange-FTP only. Not suited for XEmacs therefore.
98 (unless (featurep 'xemacs)
99 (eval-after-load "tramp"
100 '(require 'tramp-ftp)))
101
102 ;; tramp-smb uses "smbclient" from Samba.
103 ;; Not available under Cygwin and Windows, because they don't offer
104 ;; "smbclient". And even not necessary there, because Emacs supports
105 ;; UNC file names like "//host/share/localname".
106 (unless (memq system-type '(cygwin windows-nt))
107 (eval-after-load "tramp"
108 '(require 'tramp-smb)))
109
110 (eval-when-compile
111 (require 'cl)
112 (require 'custom)
113 ;; Emacs 19.34 compatibility hack -- is this needed?
114 (or (>= emacs-major-version 20)
115 (load "cl-seq")))
116
117 (unless (boundp 'custom-print-functions)
118 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4
119
120 ;; Avoid bytecompiler warnings if the byte-compiler supports this.
121 ;; Currently, XEmacs supports this.
122 (eval-when-compile
123 (when (fboundp 'byte-compiler-options)
124 (byte-compiler-options (warnings (- unused-vars)))))
125
126 ;; XEmacs is distributed with few Lisp packages. Further packages are 90 ;; XEmacs is distributed with few Lisp packages. Further packages are
127 ;; installed using EFS. If we use a unified filename format, then 91 ;; installed using EFS. If we use a unified filename format, then
128 ;; Tramp is required in addition to EFS. (But why can't Tramp just 92 ;; Tramp is required in addition to EFS. (But why can't Tramp just
129 ;; disable EFS when Tramp is loaded? Then XEmacs can ship with EFS 93 ;; disable EFS when Tramp is loaded? Then XEmacs can ship with EFS
130 ;; just like before.) Another reason for using a separate filename 94 ;; just like before.) Another reason for using a separate filename
133 ;; the other places. 97 ;; the other places.
134 ;;;###autoload 98 ;;;###autoload
135 (defvar tramp-unified-filenames (not (featurep 'xemacs)) 99 (defvar tramp-unified-filenames (not (featurep 'xemacs))
136 "Non-nil means to use unified Ange-FTP/Tramp filename syntax. 100 "Non-nil means to use unified Ange-FTP/Tramp filename syntax.
137 Nil means to use a separate filename syntax for Tramp.") 101 Nil means to use a separate filename syntax for Tramp.")
102
103 ;; Load foreign methods. Because they do require Tramp internally, this
104 ;; must be done with the `eval-after-load' trick.
105
106 ;; tramp-ftp supports Ange-FTP only. Not suited for XEmacs therefore.
107 (unless (featurep 'xemacs)
108 (eval-after-load "tramp"
109 '(require 'tramp-ftp)))
110 (when (and tramp-unified-filenames (featurep 'xemacs))
111 (eval-after-load "tramp"
112 '(require 'tramp-efs)))
113
114 ;; tramp-smb uses "smbclient" from Samba.
115 ;; Not available under Cygwin and Windows, because they don't offer
116 ;; "smbclient". And even not necessary there, because Emacs supports
117 ;; UNC file names like "//host/share/localname".
118 (unless (memq system-type '(cygwin windows-nt))
119 (eval-after-load "tramp"
120 '(require 'tramp-smb)))
121
122 (eval-when-compile
123 (require 'cl)
124 (require 'custom)
125 ;; Emacs 19.34 compatibility hack -- is this needed?
126 (or (>= emacs-major-version 20)
127 (load "cl-seq")))
128
129 (unless (boundp 'custom-print-functions)
130 (defvar custom-print-functions nil)) ; not autoloaded before Emacs 20.4
131
132 ;; Avoid bytecompiler warnings if the byte-compiler supports this.
133 ;; Currently, XEmacs supports this.
134 (eval-when-compile
135 (when (fboundp 'byte-compiler-options)
136 (byte-compiler-options (warnings (- unused-vars)))))
138 137
139 ;;; User Customizable Internal Variables: 138 ;;; User Customizable Internal Variables:
140 139
141 (defgroup tramp nil 140 (defgroup tramp nil
142 "Edit remote files with a combination of rsh and rcp or similar programs." 141 "Edit remote files with a combination of rsh and rcp or similar programs."
232 ;;- :group 'tramp 231 ;;- :group 'tramp
233 ;;- :type '(repeat character)) 232 ;;- :type '(repeat character))
234 233
235 (defcustom tramp-methods 234 (defcustom tramp-methods
236 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh) 235 '( ("rcp" (tramp-connection-function tramp-open-connection-rsh)
237 (tramp-rsh-program "rsh") 236 (tramp-login-program "rsh")
238 (tramp-rcp-program "rcp") 237 (tramp-copy-program "rcp")
239 (tramp-remote-sh "/bin/sh") 238 (tramp-remote-sh "/bin/sh")
240 (tramp-rsh-args nil) 239 (tramp-login-args nil)
241 (tramp-rcp-args nil) 240 (tramp-copy-args nil)
242 (tramp-rcp-keep-date-arg "-p") 241 (tramp-copy-keep-date-arg "-p"))
243 (tramp-su-program nil)
244 (tramp-su-args nil)
245 (tramp-telnet-program nil)
246 (tramp-telnet-args nil))
247 ("scp" (tramp-connection-function tramp-open-connection-rsh) 242 ("scp" (tramp-connection-function tramp-open-connection-rsh)
248 (tramp-rsh-program "ssh") 243 (tramp-login-program "ssh")
249 (tramp-rcp-program "scp") 244 (tramp-copy-program "scp")
250 (tramp-remote-sh "/bin/sh") 245 (tramp-remote-sh "/bin/sh")
251 (tramp-rsh-args ("-e" "none")) 246 (tramp-login-args ("-e" "none"))
252 (tramp-rcp-args nil) 247 (tramp-copy-args nil)
253 (tramp-rcp-keep-date-arg "-p") 248 (tramp-copy-keep-date-arg "-p"))
254 (tramp-su-program nil)
255 (tramp-su-args nil)
256 (tramp-telnet-program nil)
257 (tramp-telnet-args nil))
258 ("scp1" (tramp-connection-function tramp-open-connection-rsh) 249 ("scp1" (tramp-connection-function tramp-open-connection-rsh)
259 (tramp-rsh-program "ssh") 250 (tramp-login-program "ssh")
260 (tramp-rcp-program "scp") 251 (tramp-copy-program "scp")
261 (tramp-remote-sh "/bin/sh") 252 (tramp-remote-sh "/bin/sh")
262 (tramp-rsh-args ("-1" "-e" "none")) 253 (tramp-login-args ("-1" "-e" "none"))
263 (tramp-rcp-args ("-1")) 254 (tramp-copy-args ("-1"))
264 (tramp-rcp-keep-date-arg "-p") 255 (tramp-copy-keep-date-arg "-p"))
265 (tramp-su-program nil)
266 (tramp-su-args nil)
267 (tramp-telnet-program nil)
268 (tramp-telnet-args nil))
269 ("scp2" (tramp-connection-function tramp-open-connection-rsh) 256 ("scp2" (tramp-connection-function tramp-open-connection-rsh)
270 (tramp-rsh-program "ssh") 257 (tramp-login-program "ssh")
271 (tramp-rcp-program "scp") 258 (tramp-copy-program "scp")
272 (tramp-remote-sh "/bin/sh") 259 (tramp-remote-sh "/bin/sh")
273 (tramp-rsh-args ("-2" "-e" "none")) 260 (tramp-login-args ("-2" "-e" "none"))
274 (tramp-rcp-args ("-2")) 261 (tramp-copy-args ("-2"))
275 (tramp-rcp-keep-date-arg "-p") 262 (tramp-copy-keep-date-arg "-p"))
276 (tramp-su-program nil)
277 (tramp-su-args nil)
278 (tramp-telnet-program nil)
279 (tramp-telnet-args nil))
280 ("scp1_old" 263 ("scp1_old"
281 (tramp-connection-function tramp-open-connection-rsh) 264 (tramp-connection-function tramp-open-connection-rsh)
282 (tramp-rsh-program "ssh1") 265 (tramp-login-program "ssh1")
283 (tramp-rcp-program "scp1") 266 (tramp-copy-program "scp1")
284 (tramp-remote-sh "/bin/sh") 267 (tramp-remote-sh "/bin/sh")
285 (tramp-rsh-args ("-e" "none")) 268 (tramp-login-args ("-e" "none"))
286 (tramp-rcp-args nil) 269 (tramp-copy-args nil)
287 (tramp-rcp-keep-date-arg "-p") 270 (tramp-copy-keep-date-arg "-p"))
288 (tramp-su-program nil)
289 (tramp-su-args nil)
290 (tramp-telnet-program nil)
291 (tramp-telnet-args nil))
292 ("scp2_old" 271 ("scp2_old"
293 (tramp-connection-function tramp-open-connection-rsh) 272 (tramp-connection-function tramp-open-connection-rsh)
294 (tramp-rsh-program "ssh2") 273 (tramp-login-program "ssh2")
295 (tramp-rcp-program "scp2") 274 (tramp-copy-program "scp2")
296 (tramp-remote-sh "/bin/sh") 275 (tramp-remote-sh "/bin/sh")
297 (tramp-rsh-args ("-e" "none")) 276 (tramp-login-args ("-e" "none"))
298 (tramp-rcp-args nil) 277 (tramp-copy-args nil)
299 (tramp-rcp-keep-date-arg "-p") 278 (tramp-copy-keep-date-arg "-p"))
300 (tramp-su-program nil)
301 (tramp-su-args nil)
302 (tramp-telnet-program nil)
303 (tramp-telnet-args nil))
304 ("rsync" (tramp-connection-function tramp-open-connection-rsh) 279 ("rsync" (tramp-connection-function tramp-open-connection-rsh)
305 (tramp-rsh-program "ssh") 280 (tramp-login-program "ssh")
306 (tramp-rcp-program "rsync") 281 (tramp-copy-program "rsync")
307 (tramp-remote-sh "/bin/sh") 282 (tramp-remote-sh "/bin/sh")
308 (tramp-rsh-args ("-e" "none")) 283 (tramp-login-args ("-e" "none"))
309 (tramp-rcp-args ("-e" "ssh")) 284 (tramp-copy-args ("-e" "ssh"))
310 (tramp-rcp-keep-date-arg "-t") 285 (tramp-copy-keep-date-arg "-t"))
311 (tramp-su-program nil) 286 ("remcp" (tramp-connection-function tramp-open-connection-rsh)
312 (tramp-su-args nil) 287 (tramp-login-program "remsh")
313 (tramp-telnet-program nil) 288 (tramp-copy-program "rcp")
314 (tramp-telnet-args nil)) 289 (tramp-remote-sh "/bin/sh")
290 (tramp-login-args nil)
291 (tramp-copy-args nil)
292 (tramp-copy-keep-date-arg "-p"))
315 ("rsh" (tramp-connection-function tramp-open-connection-rsh) 293 ("rsh" (tramp-connection-function tramp-open-connection-rsh)
316 (tramp-rsh-program "rsh") 294 (tramp-login-program "rsh")
317 (tramp-rcp-program nil) 295 (tramp-copy-program nil)
318 (tramp-remote-sh "/bin/sh") 296 (tramp-remote-sh "/bin/sh")
319 (tramp-rsh-args nil) 297 (tramp-login-args nil)
320 (tramp-rcp-args nil) 298 (tramp-copy-args nil)
321 (tramp-rcp-keep-date-arg nil) 299 (tramp-copy-keep-date-arg nil))
322 (tramp-su-program nil)
323 (tramp-su-args nil)
324 (tramp-telnet-program nil)
325 (tramp-telnet-args nil))
326 ("ssh" (tramp-connection-function tramp-open-connection-rsh) 300 ("ssh" (tramp-connection-function tramp-open-connection-rsh)
327 (tramp-rsh-program "ssh") 301 (tramp-login-program "ssh")
328 (tramp-rcp-program nil) 302 (tramp-copy-program nil)
329 (tramp-remote-sh "/bin/sh") 303 (tramp-remote-sh "/bin/sh")
330 (tramp-rsh-args ("-e" "none")) 304 (tramp-login-args ("-e" "none"))
331 (tramp-rcp-args nil) 305 (tramp-copy-args nil)
332 (tramp-rcp-keep-date-arg nil) 306 (tramp-copy-keep-date-arg nil))
333 (tramp-su-program nil)
334 (tramp-su-args nil)
335 (tramp-telnet-program nil)
336 (tramp-telnet-args nil))
337 ("ssh1" (tramp-connection-function tramp-open-connection-rsh) 307 ("ssh1" (tramp-connection-function tramp-open-connection-rsh)
338 (tramp-rsh-program "ssh") 308 (tramp-login-program "ssh")
339 (tramp-rcp-program nil) 309 (tramp-copy-program nil)
340 (tramp-remote-sh "/bin/sh") 310 (tramp-remote-sh "/bin/sh")
341 (tramp-rsh-args ("-1" "-e" "none")) 311 (tramp-login-args ("-1" "-e" "none"))
342 (tramp-rcp-args ("-1")) 312 (tramp-copy-args ("-1"))
343 (tramp-rcp-keep-date-arg nil) 313 (tramp-copy-keep-date-arg nil))
344 (tramp-su-program nil)
345 (tramp-su-args nil)
346 (tramp-telnet-program nil)
347 (tramp-telnet-args nil))
348 ("ssh2" (tramp-connection-function tramp-open-connection-rsh) 314 ("ssh2" (tramp-connection-function tramp-open-connection-rsh)
349 (tramp-rsh-program "ssh") 315 (tramp-login-program "ssh")
350 (tramp-rcp-program nil) 316 (tramp-copy-program nil)
351 (tramp-remote-sh "/bin/sh") 317 (tramp-remote-sh "/bin/sh")
352 (tramp-rsh-args ("-2" "-e" "none")) 318 (tramp-login-args ("-2" "-e" "none"))
353 (tramp-rcp-args ("-2")) 319 (tramp-copy-args ("-2"))
354 (tramp-rcp-keep-date-arg nil) 320 (tramp-copy-keep-date-arg nil))
355 (tramp-su-program nil)
356 (tramp-su-args nil)
357 (tramp-telnet-program nil)
358 (tramp-telnet-args nil))
359 ("ssh1_old" 321 ("ssh1_old"
360 (tramp-connection-function tramp-open-connection-rsh) 322 (tramp-connection-function tramp-open-connection-rsh)
361 (tramp-rsh-program "ssh1") 323 (tramp-login-program "ssh1")
362 (tramp-rcp-program nil) 324 (tramp-copy-program nil)
363 (tramp-remote-sh "/bin/sh") 325 (tramp-remote-sh "/bin/sh")
364 (tramp-rsh-args ("-e" "none")) 326 (tramp-login-args ("-e" "none"))
365 (tramp-rcp-args nil) 327 (tramp-copy-args nil)
366 (tramp-rcp-keep-date-arg nil) 328 (tramp-copy-keep-date-arg nil))
367 (tramp-su-program nil)
368 (tramp-su-args nil)
369 (tramp-telnet-program nil)
370 (tramp-telnet-args nil))
371 ("ssh2_old" 329 ("ssh2_old"
372 (tramp-connection-function tramp-open-connection-rsh) 330 (tramp-connection-function tramp-open-connection-rsh)
373 (tramp-rsh-program "ssh2") 331 (tramp-login-program "ssh2")
374 (tramp-rcp-program nil) 332 (tramp-copy-program nil)
375 (tramp-remote-sh "/bin/sh") 333 (tramp-remote-sh "/bin/sh")
376 (tramp-rsh-args ("-e" "none")) 334 (tramp-login-args ("-e" "none"))
377 (tramp-rcp-args nil) 335 (tramp-copy-args nil)
378 (tramp-rcp-keep-date-arg nil) 336 (tramp-copy-keep-date-arg nil))
379 (tramp-su-program nil) 337 ("remsh" (tramp-connection-function tramp-open-connection-rsh)
380 (tramp-su-args nil) 338 (tramp-login-program "remsh")
381 (tramp-telnet-program nil) 339 (tramp-copy-program nil)
382 (tramp-telnet-args nil)) 340 (tramp-remote-sh "/bin/sh")
341 (tramp-login-args nil)
342 (tramp-copy-args nil)
343 (tramp-copy-keep-date-arg nil))
383 ("telnet" 344 ("telnet"
384 (tramp-connection-function tramp-open-connection-telnet) 345 (tramp-connection-function tramp-open-connection-telnet)
385 (tramp-rsh-program nil) 346 (tramp-login-program "telnet")
386 (tramp-rcp-program nil) 347 (tramp-copy-program nil)
387 (tramp-remote-sh "/bin/sh") 348 (tramp-remote-sh "/bin/sh")
388 (tramp-rsh-args nil) 349 (tramp-login-args nil)
389 (tramp-rcp-args nil) 350 (tramp-copy-args nil)
390 (tramp-rcp-keep-date-arg nil) 351 (tramp-copy-keep-date-arg nil))
391 (tramp-su-program nil)
392 (tramp-su-args nil)
393 (tramp-telnet-program "telnet")
394 (tramp-telnet-args nil))
395 ("su" (tramp-connection-function tramp-open-connection-su) 352 ("su" (tramp-connection-function tramp-open-connection-su)
396 (tramp-rsh-program nil) 353 (tramp-login-program "su")
397 (tramp-rcp-program nil) 354 (tramp-copy-program nil)
398 (tramp-remote-sh "/bin/sh") 355 (tramp-remote-sh "/bin/sh")
399 (tramp-rsh-args nil) 356 (tramp-login-args ("-" "%u"))
400 (tramp-rcp-args nil) 357 (tramp-copy-args nil)
401 (tramp-rcp-keep-date-arg nil) 358 (tramp-copy-keep-date-arg nil))
402 (tramp-su-program "su")
403 (tramp-su-args ("-" "%u"))
404 (tramp-telnet-program nil)
405 (tramp-telnet-args nil))
406 ("sudo" (tramp-connection-function tramp-open-connection-su) 359 ("sudo" (tramp-connection-function tramp-open-connection-su)
407 (tramp-rsh-program nil) 360 (tramp-login-program "sudo")
408 (tramp-rcp-program nil) 361 (tramp-copy-program nil)
409 (tramp-remote-sh "/bin/sh") 362 (tramp-remote-sh "/bin/sh")
410 (tramp-rsh-args nil) 363 (tramp-login-args ("-u" "%u" "-s"
411 (tramp-rcp-args nil) 364 "-p" "Password:"))
412 (tramp-rcp-keep-date-arg nil) 365 (tramp-copy-args nil)
413 (tramp-su-program "sudo") 366 (tramp-copy-keep-date-arg nil))
414 (tramp-su-args ("-u" "%u" "-s"))
415 (tramp-telnet-program nil)
416 (tramp-telnet-args nil))
417 ("multi" (tramp-connection-function tramp-open-connection-multi) 367 ("multi" (tramp-connection-function tramp-open-connection-multi)
418 (tramp-rsh-program nil) 368 (tramp-login-program nil)
419 (tramp-rcp-program nil) 369 (tramp-copy-program nil)
420 (tramp-remote-sh "/bin/sh") 370 (tramp-remote-sh "/bin/sh")
421 (tramp-rsh-args nil) 371 (tramp-login-args nil)
422 (tramp-rcp-args nil) 372 (tramp-copy-args nil)
423 (tramp-rcp-keep-date-arg nil) 373 (tramp-copy-keep-date-arg nil))
424 (tramp-su-program nil)
425 (tramp-su-args nil)
426 (tramp-telnet-program nil)
427 (tramp-telnet-args nil))
428 ("scpx" (tramp-connection-function tramp-open-connection-rsh) 374 ("scpx" (tramp-connection-function tramp-open-connection-rsh)
429 (tramp-rsh-program "ssh") 375 (tramp-login-program "ssh")
430 (tramp-rcp-program "scp") 376 (tramp-copy-program "scp")
431 (tramp-remote-sh "/bin/sh") 377 (tramp-remote-sh "/bin/sh")
432 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) 378 (tramp-login-args ("-e" "none" "-t" "-t" "/bin/sh"))
433 (tramp-rcp-args nil) 379 (tramp-copy-args nil)
434 (tramp-rcp-keep-date-arg "-p") 380 (tramp-copy-keep-date-arg "-p"))
435 (tramp-telnet-program nil)
436 (tramp-telnet-args nil))
437 ("sshx" (tramp-connection-function tramp-open-connection-rsh) 381 ("sshx" (tramp-connection-function tramp-open-connection-rsh)
438 (tramp-rsh-program "ssh") 382 (tramp-login-program "ssh")
439 (tramp-rcp-program nil) 383 (tramp-copy-program nil)
440 (tramp-remote-sh "/bin/sh") 384 (tramp-remote-sh "/bin/sh")
441 (tramp-rsh-args ("-e" "none" "-t" "-t" "/bin/sh")) 385 (tramp-login-args ("-e" "none" "-t" "-t" "/bin/sh"))
442 (tramp-rcp-args nil) 386 (tramp-copy-args nil)
443 (tramp-rcp-keep-date-arg nil) 387 (tramp-copy-keep-date-arg nil))
444 (tramp-su-program nil)
445 (tramp-su-args nil)
446 (tramp-telnet-program nil)
447 (tramp-telnet-args nil))
448 ("krlogin" 388 ("krlogin"
449 (tramp-connection-function tramp-open-connection-rsh) 389 (tramp-connection-function tramp-open-connection-rsh)
450 (tramp-rsh-program "krlogin") 390 (tramp-login-program "krlogin")
451 (tramp-rcp-program nil) 391 (tramp-copy-program nil)
452 (tramp-remote-sh "/bin/sh") 392 (tramp-remote-sh "/bin/sh")
453 (tramp-rsh-args ("-x")) 393 (tramp-login-args ("-x"))
454 (tramp-rcp-args nil) 394 (tramp-copy-args nil)
455 (tramp-rcp-keep-date-arg nil) 395 (tramp-copy-keep-date-arg nil))
456 (tramp-su-program nil)
457 (tramp-su-args nil)
458 (tramp-telnet-program nil)
459 (tramp-telnet-args nil))
460 ("plink" 396 ("plink"
461 (tramp-connection-function tramp-open-connection-rsh) 397 (tramp-connection-function tramp-open-connection-rsh)
462 (tramp-rsh-program "plink") 398 (tramp-login-program "plink")
463 (tramp-rcp-program nil) 399 (tramp-copy-program nil)
464 (tramp-remote-sh "/bin/sh") 400 (tramp-remote-sh "/bin/sh")
465 (tramp-rsh-args ("-ssh")) ;optionally add "-v" 401 (tramp-login-args ("-ssh")) ;optionally add "-v"
466 (tramp-rcp-args nil) 402 (tramp-copy-args nil)
467 (tramp-rcp-keep-date-arg nil) 403 (tramp-copy-keep-date-arg nil))
468 (tramp-su-program nil) 404 ("plink1"
469 (tramp-su-args nil) 405 (tramp-connection-function tramp-open-connection-rsh)
470 (tramp-telnet-program nil) 406 (tramp-login-program "plink")
471 (tramp-telnet-args nil)) 407 (tramp-copy-program nil)
408 (tramp-remote-sh "/bin/sh")
409 (tramp-login-args ("-1" "-ssh")) ;optionally add "-v"
410 (tramp-copy-args nil)
411 (tramp-copy-keep-date-arg nil))
472 ("pscp" 412 ("pscp"
473 (tramp-connection-function tramp-open-connection-rsh) 413 (tramp-connection-function tramp-open-connection-rsh)
474 (tramp-rsh-program "plink") 414 (tramp-login-program "plink")
475 (tramp-rcp-program "pscp") 415 (tramp-copy-program "pscp")
476 (tramp-remote-sh "/bin/sh") 416 (tramp-remote-sh "/bin/sh")
477 (tramp-rsh-args ("-ssh")) 417 (tramp-login-args ("-ssh"))
478 (tramp-rcp-args nil) 418 (tramp-copy-args nil)
479 (tramp-rcp-keep-date-arg "-p") 419 (tramp-copy-keep-date-arg "-p"))
480 (tramp-su-program nil)
481 (tramp-su-args nil)
482 (tramp-telnet-program nil)
483 (tramp-telnet-args nil))
484 ("fcp" 420 ("fcp"
485 (tramp-connection-function tramp-open-connection-rsh) 421 (tramp-connection-function tramp-open-connection-rsh)
486 (tramp-rsh-program "fsh") 422 (tramp-login-program "fsh")
487 (tramp-rcp-program "fcp") 423 (tramp-copy-program "fcp")
488 (tramp-remote-sh "/bin/sh -i") 424 (tramp-remote-sh "/bin/sh -i")
489 (tramp-rsh-args ("sh" "-i")) 425 (tramp-login-args ("sh" "-i"))
490 (tramp-rcp-args nil) 426 (tramp-copy-args nil)
491 (tramp-rcp-keep-date-arg "-p") 427 (tramp-copy-keep-date-arg "-p"))
492 (tramp-su-program nil)
493 (tramp-su-args nil)
494 (tramp-telnet-program nil)
495 (tramp-telnet-args nil))
496 ) 428 )
497 "*Alist of methods for remote files. 429 "*Alist of methods for remote files.
498 This is a list of entries of the form (NAME PARAM1 PARAM2 ...). 430 This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
499 Each NAME stands for a remote access method. Each PARAM is a 431 Each NAME stands for a remote access method. Each PARAM is a
500 pair of the form (KEY VALUE). The following KEYs are defined: 432 pair of the form (KEY VALUE). The following KEYs are defined:
508 MUST be a Bourne-like shell. It is normally not necessary to set 440 MUST be a Bourne-like shell. It is normally not necessary to set
509 this to any value other than \"/bin/sh\": tramp wants to use a shell 441 this to any value other than \"/bin/sh\": tramp wants to use a shell
510 which groks tilde expansion, but it can search for it. Also note 442 which groks tilde expansion, but it can search for it. Also note
511 that \"/bin/sh\" exists on all Unixen, this might not be true for 443 that \"/bin/sh\" exists on all Unixen, this might not be true for
512 the value that you decide to use. You Have Been Warned. 444 the value that you decide to use. You Have Been Warned.
513 * `tramp-rsh-program' 445 * `tramp-login-program'
514 This specifies the name of the program to use for rsh; this might be 446 This specifies the name of the program to use for logging in to the
515 the absolute filename of rsh or the name of a workalike program. 447 remote host. Depending on `tramp-connection-function', this may be
516 * `tramp-rsh-args' 448 the name of rsh or a workalike program (when
449 `tramp-connection-function' is `tramp-open-connection-rsh'), or the
450 name of telnet or a workalike (for `tramp-open-connection-telnet'),
451 or the name of su or a workalike (for `tramp-open-connection-su').
452 * `tramp-login-args'
517 This specifies the list of arguments to pass to the above 453 This specifies the list of arguments to pass to the above
518 mentioned program. Please note that this is a list of arguments, 454 mentioned program. Please note that this is a list of arguments,
519 that is, normally you don't want to put \"-a -b\" or \"-f foo\" 455 that is, normally you don't want to put \"-a -b\" or \"-f foo\"
520 here. Instead, you want two list elements, one for \"-a\" and one 456 here. Instead, you want two list elements, one for \"-a\" and one
521 for \"-b\", or one for \"-f\" and one for \"foo\". 457 for \"-b\", or one for \"-f\" and one for \"foo\".
522 * `tramp-rcp-program' 458 If `tramp-connection-function' is `tramp-open-connection-su', then
523 This specifies the name of the program to use for rcp; this might be 459 \"%u\" in this list is replaced by the user name, and \"%%\" can
524 the absolute filename of rcp or the name of a workalike program. 460 be used to obtain a literal percent character.
525 * `tramp-rcp-args' 461 * `tramp-copy-program'
462 This specifies the name of the program to use for remotely copying
463 the file; this might be the absolute filename of rcp or the name of
464 a workalike program.
465 * `tramp-copy-args'
526 This specifies the list of parameters to pass to the above mentioned 466 This specifies the list of parameters to pass to the above mentioned
527 program, the hints for `tramp-rsh-args' also apply here. 467 program, the hints for `tramp-login-args' also apply here.
528 * `tramp-rcp-keep-date-arg' 468 * `tramp-copy-keep-date-arg'
529 This specifies the parameter to use for `rcp' when the timestamp 469 This specifies the parameter to use for the copying program when the
530 of the original file should be kept. For `rcp', use `-p', for 470 timestamp of the original file should be kept. For `rcp', use `-p', for
531 `rsync', use `-t'. 471 `rsync', use `-t'.
532 * `tramp-su-program' 472
533 This specifies the name of the program to use for `su'. 473 What does all this mean? Well, you should specify `tramp-login-program'
534 * `tramp-su-args' 474 for all methods; this program is used to log in to the remote site. Then,
535 This specifies the list of arguments to pass to `su'. 475 there are two ways to actually transfer the files between the local and the
536 \"%u\" is replaced by the user name, use \"%%\" for a literal 476 remote side. One way is using an additional rcp-like program. If you want
537 percent character. 477 to do this, set `tramp-copy-program' in the method.
538 * `tramp-telnet-program'
539 Specifies the telnet program to use when using
540 `tramp-open-connection-telnet' to log in.
541 * `tramp-telnet-args'
542 Specifies list of arguments to pass to `telnet'. The hints for
543 `tramp-rsh-args' also apply here.
544
545 What does all this mean? Well, you should specify `tramp-rsh-program',
546 `tramp-telnet-program' or `tramp-su-program' for all methods; this program
547 is used to log in to the remote site. Then, there are two ways to
548 actually transfer the files between the local and the remote side.
549 One way is using an additional rcp-like program. If you want to do
550 this, set `tramp-rcp-program' in the method.
551 478
552 Another possibility for file transfer is inline transfer, i.e. the 479 Another possibility for file transfer is inline transfer, i.e. the
553 file is passed through the same buffer used by `tramp-rsh-program'. In 480 file is passed through the same buffer used by `tramp-login-program'. In
554 this case, the file contents need to be protected since the 481 this case, the file contents need to be protected since the
555 `tramp-rsh-program' might use escape codes or the connection might not 482 `tramp-login-program' might use escape codes or the connection might not
556 be eight-bit clean. Therefore, file contents are encoded for transit. 483 be eight-bit clean. Therefore, file contents are encoded for transit.
557 See the variable `tramp-coding-commands' for details. 484 See the variable `tramp-coding-commands' for details.
558 485
559 So, to summarize: if the method is an out-of-band method, then you 486 So, to summarize: if the method is an out-of-band method, then you
560 must specify `tramp-rcp-program' and `tramp-rcp-args'. If it is an 487 must specify `tramp-copy-program' and `tramp-copy-args'. If it is an
561 inline method, then these two parameters should be nil. Every method, 488 inline method, then these two parameters should be nil. Every method,
562 inline or out of band, must specify `tramp-connection-function' plus 489 inline or out of band, must specify `tramp-connection-function' plus
563 the associated arguments (for example, the telnet program if you chose 490 the associated arguments (for example, the login program if you chose
564 `tramp-open-connection-telnet'). 491 `tramp-open-connection-telnet').
565 492
566 Notes: 493 Notes:
567 494
568 When using `tramp-open-connection-su' the phrase `open connection to a 495 When using `tramp-open-connection-su' the phrase `open connection to a
572 host other than `localhost' or the name of the local host." 499 host other than `localhost' or the name of the local host."
573 :group 'tramp 500 :group 'tramp
574 :type '(repeat 501 :type '(repeat
575 (cons string 502 (cons string
576 (set (list (const tramp-connection-function) function) 503 (set (list (const tramp-connection-function) function)
577 (list (const tramp-rsh-program) 504 (list (const tramp-login-program)
578 (choice (const nil) string)) 505 (choice (const nil) string))
579 (list (const tramp-rcp-program) 506 (list (const tramp-copy-program)
580 (choice (const nil) string)) 507 (choice (const nil) string))
581 (list (const tramp-remote-sh) 508 (list (const tramp-remote-sh)
582 (choice (const nil) string)) 509 (choice (const nil) string))
583 (list (const tramp-rsh-args) (repeat string)) 510 (list (const tramp-login-args) (repeat string))
584 (list (const tramp-rcp-args) (repeat string)) 511 (list (const tramp-copy-args) (repeat string))
585 (list (const tramp-rcp-keep-date-arg) 512 (list (const tramp-copy-keep-date-arg)
586 (choice (const nil) string)) 513 (choice (const nil) string))
587 (list (const tramp-su-program)
588 (choice (const nil) string))
589 (list (const tramp-su-args) (repeat string))
590 (list (const tramp-encoding-command) 514 (list (const tramp-encoding-command)
591 (choice (const nil) string)) 515 (choice (const nil) string))
592 (list (const tramp-decoding-command) 516 (list (const tramp-decoding-command)
593 (choice (const nil) string)) 517 (choice (const nil) string))
594 (list (const tramp-encoding-function) 518 (list (const tramp-encoding-function)
595 (choice (const nil) function)) 519 (choice (const nil) function))
596 (list (const tramp-decoding-function) 520 (list (const tramp-decoding-function)
597 (choice (const nil) function)) 521 (choice (const nil) function))))))
598 (list (const tramp-telnet-program)
599 (choice (const nil) string))
600 (list (const tramp-telnet-args) (repeat string))))))
601 522
602 (defcustom tramp-multi-methods '("multi" "multiu") 523 (defcustom tramp-multi-methods '("multi" "multiu")
603 "*List of multi-hop methods. 524 "*List of multi-hop methods.
604 Each entry in this list should be a method name as mentioned in the 525 Each entry in this list should be a method name as mentioned in the
605 variable `tramp-methods'." 526 variable `tramp-methods'."
607 :type '(repeat string)) 528 :type '(repeat string))
608 529
609 (defcustom tramp-multi-connection-function-alist 530 (defcustom tramp-multi-connection-function-alist
610 '(("telnet" tramp-multi-connect-telnet "telnet %h%n") 531 '(("telnet" tramp-multi-connect-telnet "telnet %h%n")
611 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n") 532 ("rsh" tramp-multi-connect-rlogin "rsh %h -l %u%n")
533 ("remsh" tramp-multi-connect-rlogin "remsh %h -l %u%n")
612 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n") 534 ("ssh" tramp-multi-connect-rlogin "ssh %h -l %u%n")
613 ("su" tramp-multi-connect-su "su - %u%n") 535 ("su" tramp-multi-connect-su "su - %u%n")
614 ("sudo" tramp-multi-connect-su "sudo -u %u -s%n")) 536 ("sudo" tramp-multi-connect-su "sudo -u %u -s -p Password:%n"))
615 "*List of connection functions for multi-hop methods. 537 "*List of connection functions for multi-hop methods.
616 Each list item is a list of three items (METHOD FUNCTION COMMAND), 538 Each list item is a list of three items (METHOD FUNCTION COMMAND),
617 where METHOD is the name as used in the file name, FUNCTION is the 539 where METHOD is the name as used in the file name, FUNCTION is the
618 function to be executed, and COMMAND is the shell command used for 540 function to be executed, and COMMAND is the shell command used for
619 connecting. 541 connecting.
627 function `tramp-multi-connect-telnet'. See the documentation of the 549 function `tramp-multi-connect-telnet'. See the documentation of the
628 various functions for details." 550 various functions for details."
629 :group 'tramp 551 :group 'tramp
630 :type '(repeat (list string function string))) 552 :type '(repeat (list string function string)))
631 553
632 (defcustom tramp-default-method "ssh" 554 (defcustom tramp-default-method
555 (if (and (fboundp 'executable-find)
556 (executable-find "plink"))
557 "plink"
558 "ssh")
633 "*Default method to use for transferring files. 559 "*Default method to use for transferring files.
634 See `tramp-methods' for possibilities. 560 See `tramp-methods' for possibilities.
635 Also see `tramp-default-method-alist'." 561 Also see `tramp-default-method-alist'."
636 :group 'tramp 562 :group 'tramp
637 :type 'string) 563 :type 'string)
657 ;; Default values for non-Unices seeked 583 ;; Default values for non-Unices seeked
658 (defconst tramp-completion-function-alist-rsh 584 (defconst tramp-completion-function-alist-rsh
659 (unless (memq system-type '(windows-nt)) 585 (unless (memq system-type '(windows-nt))
660 '((tramp-parse-rhosts "/etc/hosts.equiv") 586 '((tramp-parse-rhosts "/etc/hosts.equiv")
661 (tramp-parse-rhosts "~/.rhosts"))) 587 (tramp-parse-rhosts "~/.rhosts")))
662 "Default list of (FUNCTION FILE) pairs to be examined for rsh methods." 588 "Default list of (FUNCTION FILE) pairs to be examined for rsh methods.")
663 )
664 589
665 ;; Default values for non-Unices seeked 590 ;; Default values for non-Unices seeked
666 (defconst tramp-completion-function-alist-ssh 591 (defconst tramp-completion-function-alist-ssh
667 (unless (memq system-type '(windows-nt)) 592 (unless (memq system-type '(windows-nt))
668 '((tramp-parse-rhosts "/etc/hosts.equiv") 593 '((tramp-parse-rhosts "/etc/hosts.equiv")
671 (tramp-parse-sconfig "/etc/ssh_config") 596 (tramp-parse-sconfig "/etc/ssh_config")
672 (tramp-parse-rhosts "~/.rhosts") 597 (tramp-parse-rhosts "~/.rhosts")
673 (tramp-parse-rhosts "~/.shosts") 598 (tramp-parse-rhosts "~/.shosts")
674 (tramp-parse-shosts "~/.ssh/known_hosts") 599 (tramp-parse-shosts "~/.ssh/known_hosts")
675 (tramp-parse-sconfig "~/.ssh/config"))) 600 (tramp-parse-sconfig "~/.ssh/config")))
676 "Default list of (FUNCTION FILE) pairs to be examined for ssh methods." 601 "Default list of (FUNCTION FILE) pairs to be examined for ssh methods.")
677 )
678 602
679 ;; Default values for non-Unices seeked 603 ;; Default values for non-Unices seeked
680 (defconst tramp-completion-function-alist-telnet 604 (defconst tramp-completion-function-alist-telnet
681 (unless (memq system-type '(windows-nt)) 605 (unless (memq system-type '(windows-nt))
682 '((tramp-parse-hosts "/etc/hosts"))) 606 '((tramp-parse-hosts "/etc/hosts")))
683 "Default list of (FUNCTION FILE) pairs to be examined for telnet methods." 607 "Default list of (FUNCTION FILE) pairs to be examined for telnet methods.")
684 )
685 608
686 ;; Default values for non-Unices seeked 609 ;; Default values for non-Unices seeked
687 (defconst tramp-completion-function-alist-su 610 (defconst tramp-completion-function-alist-su
688 (unless (memq system-type '(windows-nt)) 611 (unless (memq system-type '(windows-nt))
689 '((tramp-parse-passwd "/etc/passwd"))) 612 '((tramp-parse-passwd "/etc/passwd")))
690 "Default list of (FUNCTION FILE) pairs to be examined for su methods." 613 "Default list of (FUNCTION FILE) pairs to be examined for su methods.")
691 )
692 614
693 (defcustom tramp-completion-function-alist 615 (defcustom tramp-completion-function-alist
694 (list (cons "rcp" tramp-completion-function-alist-rsh) 616 (list (cons "rcp" tramp-completion-function-alist-rsh)
695 (cons "scp" tramp-completion-function-alist-ssh) 617 (cons "scp" tramp-completion-function-alist-ssh)
696 (cons "scp1" tramp-completion-function-alist-ssh) 618 (cons "scp1" tramp-completion-function-alist-ssh)
772 The regexp should match at end of buffer." 694 The regexp should match at end of buffer."
773 :group 'tramp 695 :group 'tramp
774 :type 'regexp) 696 :type 'regexp)
775 697
776 (defcustom tramp-shell-prompt-pattern 698 (defcustom tramp-shell-prompt-pattern
777 "^[^#$%>\n]*[#$%>] *" 699 "^[^#$%>\n]*[#$%>] *\\(\e\\[[0-9;]*[a-zA-Z]\\)?"
778 "Regexp to match prompts from remote shell. 700 "Regexp to match prompts from remote shell.
779 Normally, Tramp expects you to configure `shell-prompt-pattern' 701 Normally, Tramp expects you to configure `shell-prompt-pattern'
780 correctly, but sometimes it happens that you are connecting to a 702 correctly, but sometimes it happens that you are connecting to a
781 remote host which sends a different kind of shell prompt. Therefore, 703 remote host which sends a different kind of shell prompt. Therefore,
782 Tramp recognizes things matched by `shell-prompt-pattern' as prompt, 704 Tramp recognizes things matched by `shell-prompt-pattern' as prompt,
783 and also things matched by this variable. The default value of this 705 and also things matched by this variable. The default value of this
784 variable is the same as the default value of `shell-prompt-pattern', 706 variable is similar to the default value of `shell-prompt-pattern',
785 which should work well in many cases." 707 which should work well in many cases."
786 :group 'tramp 708 :group 'tramp
787 :type 'regexp) 709 :type 'regexp)
788 710
789 (defcustom tramp-password-prompt-regexp 711 (defcustom tramp-password-prompt-regexp
1313 (defvar tramp-remote-sh nil 1235 (defvar tramp-remote-sh nil
1314 "This internal variable holds a parameter for `tramp-methods'. 1236 "This internal variable holds a parameter for `tramp-methods'.
1315 In the connection buffer, this variable has the value of the like-named 1237 In the connection buffer, this variable has the value of the like-named
1316 method parameter, as specified in `tramp-methods' (which see).") 1238 method parameter, as specified in `tramp-methods' (which see).")
1317 1239
1318 (defvar tramp-rsh-program nil 1240 (defvar tramp-login-program nil
1319 "This internal variable holds a parameter for `tramp-methods'. 1241 "This internal variable holds a parameter for `tramp-methods'.
1320 In the connection buffer, this variable has the value of the like-named 1242 In the connection buffer, this variable has the value of the like-named
1321 method parameter, as specified in `tramp-methods' (which see).") 1243 method parameter, as specified in `tramp-methods' (which see).")
1322 1244
1323 (defvar tramp-rsh-args nil 1245 (defvar tramp-login-args nil
1324 "This internal variable holds a parameter for `tramp-methods'. 1246 "This internal variable holds a parameter for `tramp-methods'.
1325 In the connection buffer, this variable has the value of the like-named 1247 In the connection buffer, this variable has the value of the like-named
1326 method parameter, as specified in `tramp-methods' (which see).") 1248 method parameter, as specified in `tramp-methods' (which see).")
1327 1249
1328 (defvar tramp-rcp-program nil 1250 (defvar tramp-copy-program nil
1329 "This internal variable holds a parameter for `tramp-methods'. 1251 "This internal variable holds a parameter for `tramp-methods'.
1330 In the connection buffer, this variable has the value of the like-named 1252 In the connection buffer, this variable has the value of the like-named
1331 method parameter, as specified in `tramp-methods' (which see).") 1253 method parameter, as specified in `tramp-methods' (which see).")
1332 1254
1333 (defvar tramp-rcp-args nil 1255 (defvar tramp-copy-args nil
1334 "This internal variable holds a parameter for `tramp-methods'. 1256 "This internal variable holds a parameter for `tramp-methods'.
1335 In the connection buffer, this variable has the value of the like-named 1257 In the connection buffer, this variable has the value of the like-named
1336 method parameter, as specified in `tramp-methods' (which see).") 1258 method parameter, as specified in `tramp-methods' (which see).")
1337 1259
1338 (defvar tramp-rcp-keep-date-arg nil 1260 (defvar tramp-copy-keep-date-arg nil
1339 "This internal variable holds a parameter for `tramp-methods'. 1261 "This internal variable holds a parameter for `tramp-methods'.
1340 In the connection buffer, this variable has the value of the like-named 1262 In the connection buffer, this variable has the value of the like-named
1341 method parameter, as specified in `tramp-methods' (which see).") 1263 method parameter, as specified in `tramp-methods' (which see).")
1342 1264
1343 (defvar tramp-encoding-command nil 1265 (defvar tramp-encoding-command nil
1354 "This internal variable holds a parameter for `tramp-methods'. 1276 "This internal variable holds a parameter for `tramp-methods'.
1355 In the connection buffer, this variable has the value of the like-named 1277 In the connection buffer, this variable has the value of the like-named
1356 method parameter, as specified in `tramp-methods' (which see).") 1278 method parameter, as specified in `tramp-methods' (which see).")
1357 1279
1358 (defvar tramp-decoding-function nil 1280 (defvar tramp-decoding-function nil
1359 "This internal variable holds a parameter for `tramp-methods'.
1360 In the connection buffer, this variable has the value of the like-named
1361 method parameter, as specified in `tramp-methods' (which see).")
1362
1363 (defvar tramp-telnet-program nil
1364 "This internal variable holds a parameter for `tramp-methods'.
1365 In the connection buffer, this variable has the value of the like-named
1366 method parameter, as specified in `tramp-methods' (which see).")
1367
1368 (defvar tramp-telnet-args nil
1369 "This internal variable holds a parameter for `tramp-methods'.
1370 In the connection buffer, this variable has the value of the like-named
1371 method parameter, as specified in `tramp-methods' (which see).")
1372
1373 (defvar tramp-su-program nil
1374 "This internal variable holds a parameter for `tramp-methods'. 1281 "This internal variable holds a parameter for `tramp-methods'.
1375 In the connection buffer, this variable has the value of the like-named 1282 In the connection buffer, this variable has the value of the like-named
1376 method parameter, as specified in `tramp-methods' (which see).") 1283 method parameter, as specified in `tramp-methods' (which see).")
1377 1284
1378 ;; CCC `local in each buffer'? 1285 ;; CCC `local in each buffer'?
1942 multi-method method user host 1849 multi-method method user host
1943 10 "Follow symlink to %s" symlink-target) 1850 10 "Follow symlink to %s" symlink-target)
1944 (setq numchase (1+ numchase)) 1851 (setq numchase (1+ numchase))
1945 (when (file-name-absolute-p symlink-target) 1852 (when (file-name-absolute-p symlink-target)
1946 (setq result nil)) 1853 (setq result nil))
1854 ;; If the symlink was absolute, we'll get a string like
1855 ;; "/user@host:/some/target"; extract the
1856 ;; "/some/target" part from it.
1857 (when (tramp-tramp-file-p symlink-target)
1858 (with-parsed-tramp-file-name symlink-target sym
1859 (unless (equal (list multi-method method user host)
1860 (list sym-multi-method sym-method
1861 sym-user sym-host))
1862 (error "Symlink target `%s' on wrong host"
1863 symlink-target))
1864 (setq symlink-target localname)))
1947 (setq steps 1865 (setq steps
1948 (append (tramp-split-string symlink-target "/") steps))) 1866 (append (tramp-split-string symlink-target "/") steps)))
1949 (t 1867 (t
1950 ;; It's a file. 1868 ;; It's a file.
1951 (setq result (cons thisstep result))))) 1869 (setq result (cons thisstep result)))))
2319 2237
2320 (defun tramp-handle-file-symlink-p (filename) 2238 (defun tramp-handle-file-symlink-p (filename)
2321 "Like `file-symlink-p' for tramp files." 2239 "Like `file-symlink-p' for tramp files."
2322 (with-parsed-tramp-file-name filename nil 2240 (with-parsed-tramp-file-name filename nil
2323 (let ((x (car (tramp-handle-file-attributes filename)))) 2241 (let ((x (car (tramp-handle-file-attributes filename))))
2324 (when (stringp x) x)))) 2242 (when (stringp x)
2243 ;; When Tramp is running on VMS, then `file-name-absolute-p'
2244 ;; might do weird things.
2245 (if (file-name-absolute-p x)
2246 (tramp-make-tramp-file-name
2247 multi-method method user host x)
2248 x)))))
2325 2249
2326 (defun tramp-handle-file-writable-p (filename) 2250 (defun tramp-handle-file-writable-p (filename)
2327 "Like `file-writable-p' for tramp files." 2251 "Like `file-writable-p' for tramp files."
2328 (with-parsed-tramp-file-name filename nil 2252 (with-parsed-tramp-file-name filename nil
2329 (if (tramp-handle-file-exists-p filename) 2253 (if (tramp-handle-file-exists-p filename)
2602 ;; the target file. The advantage is that it doesn't 2526 ;; the target file. The advantage is that it doesn't
2603 ;; matter which filename handlers are used for the 2527 ;; matter which filename handlers are used for the
2604 ;; source and target file. 2528 ;; source and target file.
2605 2529
2606 ;; CCC: If both source and target are Tramp files, 2530 ;; CCC: If both source and target are Tramp files,
2607 ;; and both are using the same rcp-program, then we 2531 ;; and both are using the same copy-program, then we
2608 ;; can invoke rcp directly. Note that 2532 ;; can invoke rcp directly. Note that
2609 ;; default-directory should point to a local 2533 ;; default-directory should point to a local
2610 ;; directory if we want to invoke rcp. 2534 ;; directory if we want to invoke rcp.
2611 (tramp-do-copy-or-rename-via-buffer 2535 (tramp-do-copy-or-rename-via-buffer
2612 op filename newname keep-date))))) 2536 op filename newname keep-date)))))
2920 ;; expand-file-name (this does "/./" and "/../"). We bind 2844 ;; expand-file-name (this does "/./" and "/../"). We bind
2921 ;; directory-sep-char here for XEmacs on Windows, which 2845 ;; directory-sep-char here for XEmacs on Windows, which
2922 ;; would otherwise use backslash. 2846 ;; would otherwise use backslash.
2923 (let ((directory-sep-char ?/)) 2847 (let ((directory-sep-char ?/))
2924 (tramp-make-tramp-file-name 2848 (tramp-make-tramp-file-name
2925 multi-method method user host 2849 multi-method (or method (tramp-find-default-method user host))
2850 user host
2926 (tramp-drop-volume-letter 2851 (tramp-drop-volume-letter
2927 (tramp-run-real-handler 'expand-file-name 2852 (tramp-run-real-handler 'expand-file-name
2928 (list localname))))))))) 2853 (list localname)))))))))
2929 2854
2930 ;; old version follows. it uses ".." to cross file handler 2855 ;; old version follows. it uses ".." to cross file handler
3010 (defun tramp-handle-file-local-copy (filename) 2935 (defun tramp-handle-file-local-copy (filename)
3011 "Like `file-local-copy' for tramp files." 2936 "Like `file-local-copy' for tramp files."
3012 (with-parsed-tramp-file-name filename nil 2937 (with-parsed-tramp-file-name filename nil
3013 (let ((output-buf (get-buffer-create "*tramp output*")) 2938 (let ((output-buf (get-buffer-create "*tramp output*"))
3014 (tramp-buf (tramp-get-buffer multi-method method user host)) 2939 (tramp-buf (tramp-get-buffer multi-method method user host))
3015 (rcp-program (tramp-get-rcp-program 2940 (copy-program (tramp-get-copy-program
3016 multi-method 2941 multi-method
3017 (tramp-find-method multi-method method user host) 2942 (tramp-find-method multi-method method user host)
3018 user host)) 2943 user host))
3019 (rcp-args (tramp-get-rcp-args 2944 (copy-args (tramp-get-copy-args
3020 multi-method 2945 multi-method
3021 (tramp-find-method multi-method method user host) 2946 (tramp-find-method multi-method method user host)
3022 user host)) 2947 user host))
3023 ;; We used to bind the following as late as possible. 2948 ;; We used to bind the following as late as possible.
3024 ;; loc-enc and loc-dec were bound directly before the if 2949 ;; loc-enc and loc-dec were bound directly before the if
3025 ;; statement that checks them. But the functions 2950 ;; statement that checks them. But the functions
3026 ;; tramp-get-* might invoke the "are you awake" check in 2951 ;; tramp-get-* might invoke the "are you awake" check in
3027 ;; tramp-maybe-open-connection, which is an unfortunate time 2952 ;; tramp-maybe-open-connection, which is an unfortunate time
3033 tmpfil) 2958 tmpfil)
3034 (unless (file-exists-p filename) 2959 (unless (file-exists-p filename)
3035 (error "Cannot make local copy of non-existing file `%s'" 2960 (error "Cannot make local copy of non-existing file `%s'"
3036 filename)) 2961 filename))
3037 (setq tmpfil (tramp-make-temp-file)) 2962 (setq tmpfil (tramp-make-temp-file))
3038 (cond (rcp-program 2963 (cond (copy-program
3039 ;; Use rcp-like program for file transfer. 2964 ;; Use rcp-like program for file transfer.
3040 (tramp-message-for-buffer 2965 (tramp-message-for-buffer
3041 multi-method method user host 2966 multi-method method user host
3042 5 "Fetching %s to tmp file %s..." filename tmpfil) 2967 5 "Fetching %s to tmp file %s..." filename tmpfil)
3043 (save-excursion (set-buffer output-buf) (erase-buffer)) 2968 (save-excursion (set-buffer output-buf) (erase-buffer))
3044 (unless (equal 2969 (unless (equal
3045 0 2970 0
3046 (apply #'call-process 2971 (apply #'call-process
3047 rcp-program 2972 copy-program
3048 nil output-buf nil 2973 nil output-buf nil
3049 (append rcp-args 2974 (append copy-args
3050 (list 2975 (list
3051 (tramp-make-rcp-program-file-name 2976 (tramp-make-copy-program-file-name
3052 user host 2977 user host
3053 (tramp-shell-quote-argument localname)) 2978 (tramp-shell-quote-argument localname))
3054 tmpfil)))) 2979 tmpfil))))
3055 (pop-to-buffer output-buf) 2980 (pop-to-buffer output-buf)
3056 (error 2981 (error
3057 (concat "tramp-handle-file-local-copy: `%s' didn't work, " 2982 (concat "tramp-handle-file-local-copy: `%s' didn't work, "
3058 "see buffer `%s' for details") 2983 "see buffer `%s' for details")
3059 rcp-program output-buf)) 2984 copy-program output-buf))
3060 (tramp-message-for-buffer 2985 (tramp-message-for-buffer
3061 multi-method method user host 2986 multi-method method user host
3062 5 "Fetching %s to tmp file %s...done" filename tmpfil)) 2987 5 "Fetching %s to tmp file %s...done" filename tmpfil))
3063 ((and rem-enc rem-dec) 2988 ((and rem-enc rem-dec)
3064 ;; Use inline encoding for file transfer. 2989 ;; Use inline encoding for file transfer.
3178 (unless (y-or-n-p (format "File %s exists; overwrite anyway? " 3103 (unless (y-or-n-p (format "File %s exists; overwrite anyway? "
3179 filename)) 3104 filename))
3180 (error "File not overwritten"))) 3105 (error "File not overwritten")))
3181 (with-parsed-tramp-file-name filename nil 3106 (with-parsed-tramp-file-name filename nil
3182 (let ((curbuf (current-buffer)) 3107 (let ((curbuf (current-buffer))
3183 (rcp-program (tramp-get-rcp-program 3108 (copy-program (tramp-get-copy-program
3184 multi-method (tramp-find-method multi-method method user host) 3109 multi-method
3185 user host)) 3110 (tramp-find-method multi-method method user host)
3186 (rcp-args (tramp-get-rcp-args 3111 user host))
3112 (copy-args (tramp-get-copy-args
3187 multi-method 3113 multi-method
3188 (tramp-find-method multi-method method user host) 3114 (tramp-find-method multi-method method user host)
3189 user host)) 3115 user host))
3190 (rem-enc (tramp-get-remote-encoding multi-method method user host)) 3116 (rem-enc (tramp-get-remote-encoding multi-method method user host))
3191 (rem-dec (tramp-get-remote-decoding multi-method method user host)) 3117 (rem-dec (tramp-get-remote-decoding multi-method method user host))
3219 ;; file transfer. First, we check whether the method uses an rcp 3145 ;; file transfer. First, we check whether the method uses an rcp
3220 ;; program. If so, we call it. Otherwise, both encoding and 3146 ;; program. If so, we call it. Otherwise, both encoding and
3221 ;; decoding command must be specified. However, if the method 3147 ;; decoding command must be specified. However, if the method
3222 ;; _also_ specifies an encoding function, then that is used for 3148 ;; _also_ specifies an encoding function, then that is used for
3223 ;; encoding the contents of the tmp file. 3149 ;; encoding the contents of the tmp file.
3224 (cond (rcp-program 3150 (cond (copy-program
3225 ;; use rcp-like program for file transfer 3151 ;; use rcp-like program for file transfer
3226 (let ((argl (append rcp-args 3152 (let ((argl (append copy-args
3227 (list 3153 (list
3228 tmpfil 3154 tmpfil
3229 (tramp-make-rcp-program-file-name 3155 (tramp-make-copy-program-file-name
3230 user host 3156 user host
3231 (tramp-shell-quote-argument localname)))))) 3157 (tramp-shell-quote-argument localname))))))
3232 (tramp-message-for-buffer 3158 (tramp-message-for-buffer
3233 multi-method method user host 3159 multi-method method user host
3234 6 "Writing tmp file using `%s'..." rcp-program) 3160 6 "Writing tmp file using `%s'..." copy-program)
3235 (save-excursion (set-buffer trampbuf) (erase-buffer)) 3161 (save-excursion (set-buffer trampbuf) (erase-buffer))
3236 (when tramp-debug-buffer 3162 (when tramp-debug-buffer
3237 (save-excursion 3163 (save-excursion
3238 (set-buffer (tramp-get-debug-buffer multi-method 3164 (set-buffer (tramp-get-debug-buffer multi-method
3239 method user host)) 3165 method user host))
3240 (goto-char (point-max)) 3166 (goto-char (point-max))
3241 (tramp-insert-with-face 3167 (tramp-insert-with-face
3242 'bold (format "$ %s %s\n" rcp-program 3168 'bold (format "$ %s %s\n" copy-program
3243 (mapconcat 'identity argl " "))))) 3169 (mapconcat 'identity argl " ")))))
3244 (unless (equal 0 3170 (unless (equal 0
3245 (apply #'call-process 3171 (apply #'call-process
3246 rcp-program nil trampbuf nil argl)) 3172 copy-program nil trampbuf nil argl))
3247 (pop-to-buffer trampbuf) 3173 (pop-to-buffer trampbuf)
3248 (error 3174 (error
3249 "Cannot write region to file `%s', command `%s' failed" 3175 "Cannot write region to file `%s', command `%s' failed"
3250 filename rcp-program)) 3176 filename copy-program))
3251 (tramp-message-for-buffer 3177 (tramp-message-for-buffer
3252 multi-method method user host 3178 multi-method method user host
3253 6 "Transferring file using `%s'...done" 3179 6 "Transferring file using `%s'...done"
3254 rcp-program))) 3180 copy-program)))
3255 ((and rem-enc rem-dec) 3181 ((and rem-enc rem-dec)
3256 ;; Use inline file transfer 3182 ;; Use inline file transfer
3257 (let ((tmpbuf (get-buffer-create " *tramp file transfer*"))) 3183 (let ((tmpbuf (get-buffer-create " *tramp file transfer*")))
3258 (save-excursion 3184 (save-excursion
3259 ;; Encode tmpfil into tmpbuf 3185 ;; Encode tmpfil into tmpbuf
3503 (cond 3429 (cond
3504 (foreign (apply foreign operation args)) 3430 (foreign (apply foreign operation args))
3505 (fn (apply (cdr fn) args)) 3431 (fn (apply (cdr fn) args))
3506 (t (tramp-run-real-handler operation args)))))) 3432 (t (tramp-run-real-handler operation args))))))
3507 3433
3434 ;;;###autoload
3508 (put 'tramp-file-name-handler 'file-remote-p t) ;for file-remote-p 3435 (put 'tramp-file-name-handler 'file-remote-p t) ;for file-remote-p
3509 3436
3510 ;;;###autoload 3437 ;;;###autoload
3511 (defun tramp-completion-file-name-handler (operation &rest args) 3438 (defun tramp-completion-file-name-handler (operation &rest args)
3512 "Invoke tramp file name completion handler. 3439 "Invoke tramp file name completion handler.
3517 ;; operation args (with-output-to-string (backtrace))) 3444 ;; operation args (with-output-to-string (backtrace)))
3518 (let ((fn (assoc operation tramp-completion-file-name-handler-alist))) 3445 (let ((fn (assoc operation tramp-completion-file-name-handler-alist)))
3519 (if fn 3446 (if fn
3520 (save-match-data (apply (cdr fn) args)) 3447 (save-match-data (apply (cdr fn) args))
3521 (tramp-completion-run-real-handler operation args)))) 3448 (tramp-completion-run-real-handler operation args))))
3449
3450 ;;;###autoload
3451 (put 'tramp-completion-file-name-handler 'safe-magic t)
3522 3452
3523 ;; Register in file name handler alist 3453 ;; Register in file name handler alist
3524 ;;;###autoload 3454 ;;;###autoload
3525 (add-to-list 'file-name-handler-alist 3455 (add-to-list 'file-name-handler-alist
3526 (cons tramp-file-name-regexp 'tramp-file-name-handler)) 3456 (cons tramp-file-name-regexp 'tramp-file-name-handler))
4606 (> emacs-major-version 20)) 4536 (> emacs-major-version 20))
4607 tramp-dos-coding-system)) 4537 tramp-dos-coding-system))
4608 (p (apply 'start-process 4538 (p (apply 'start-process
4609 (tramp-buffer-name multi-method method user host) 4539 (tramp-buffer-name multi-method method user host)
4610 (tramp-get-buffer multi-method method user host) 4540 (tramp-get-buffer multi-method method user host)
4611 (tramp-get-telnet-program 4541 (tramp-get-login-program
4612 multi-method 4542 multi-method
4613 (tramp-find-method multi-method method user host) 4543 (tramp-find-method multi-method method user host)
4614 user host) 4544 user host)
4615 host 4545 host
4616 (tramp-get-telnet-args 4546 (tramp-get-login-args
4617 multi-method 4547 multi-method
4618 (tramp-find-method multi-method method user host) 4548 (tramp-find-method multi-method method user host)
4619 user host))) 4549 user host)))
4620 (found nil) 4550 (found nil)
4621 (pw nil)) 4551 (pw nil))
4663 user host method) 4593 user host method)
4664 (tramp-message 7 "Opening connection at %s using %s..." host method)) 4594 (tramp-message 7 "Opening connection at %s using %s..." host method))
4665 (let ((process-environment (copy-sequence process-environment)) 4595 (let ((process-environment (copy-sequence process-environment))
4666 (bufnam (tramp-buffer-name multi-method method user host)) 4596 (bufnam (tramp-buffer-name multi-method method user host))
4667 (buf (tramp-get-buffer multi-method method user host)) 4597 (buf (tramp-get-buffer multi-method method user host))
4668 (rsh-program (tramp-get-rsh-program 4598 (login-program (tramp-get-login-program
4669 multi-method 4599 multi-method
4670 (tramp-find-method multi-method method user host) 4600 (tramp-find-method multi-method method user host)
4671 user host)) 4601 user host))
4672 (rsh-args (tramp-get-rsh-args 4602 (login-args (tramp-get-login-args
4673 multi-method 4603 multi-method
4674 (tramp-find-method multi-method method user host) 4604 (tramp-find-method multi-method method user host)
4675 user host))) 4605 user host)))
4676 ;; The following should be changed. We need a more general 4606 ;; The following should be changed. We need a more general
4677 ;; mechanism to parse extra host args. 4607 ;; mechanism to parse extra host args.
4678 (when (string-match "\\([^#]*\\)#\\(.*\\)" host) 4608 (when (string-match "\\([^#]*\\)#\\(.*\\)" host)
4679 (setq rsh-args (cons "-p" (cons (match-string 2 host) rsh-args))) 4609 (setq login-args (cons "-p" (cons (match-string 2 host) rsh-args)))
4680 (setq host (match-string 1 host))) 4610 (setq host (match-string 1 host)))
4681 (setenv "TERM" tramp-terminal-type) 4611 (setenv "TERM" tramp-terminal-type)
4682 (let* ((default-directory (tramp-temporary-file-directory)) 4612 (let* ((default-directory (tramp-temporary-file-directory))
4683 ;; If we omit the conditional, we would use 4613 ;; If we omit the conditional, we would use
4684 ;; `undecided-dos' in some cases. With the conditional, 4614 ;; `undecided-dos' in some cases. With the conditional,
4685 ;; we use nil in these cases. Which one is right? 4615 ;; we use nil in these cases. Which one is right?
4686 (coding-system-for-read (unless (and (not (featurep 'xemacs)) 4616 (coding-system-for-read (unless (and (not (featurep 'xemacs))
4687 (> emacs-major-version 20)) 4617 (> emacs-major-version 20))
4688 tramp-dos-coding-system)) 4618 tramp-dos-coding-system))
4689 (p (if (and user (not (string= user ""))) 4619 (p (if (and user (not (string= user "")))
4690 (apply #'start-process bufnam buf rsh-program 4620 (apply #'start-process bufnam buf login-program
4691 host "-l" user rsh-args) 4621 host "-l" user login-args)
4692 (apply #'start-process bufnam buf rsh-program 4622 (apply #'start-process bufnam buf login-program
4693 host rsh-args))) 4623 host login-args)))
4694 (found nil)) 4624 (found nil))
4695 (process-kill-without-query p) 4625 (process-kill-without-query p)
4696 4626
4697 (set-buffer buf) 4627 (set-buffer buf)
4698 (tramp-process-actions p multi-method method user host 4628 (tramp-process-actions p multi-method method user host
4738 (> emacs-major-version 20)) 4668 (> emacs-major-version 20))
4739 tramp-dos-coding-system)) 4669 tramp-dos-coding-system))
4740 (p (apply 'start-process 4670 (p (apply 'start-process
4741 (tramp-buffer-name multi-method method user host) 4671 (tramp-buffer-name multi-method method user host)
4742 (tramp-get-buffer multi-method method user host) 4672 (tramp-get-buffer multi-method method user host)
4743 (tramp-get-su-program 4673 (tramp-get-login-program
4744 multi-method 4674 multi-method
4745 (tramp-find-method multi-method method user host) 4675 (tramp-find-method multi-method method user host)
4746 user host) 4676 user host)
4747 (mapcar 4677 (mapcar
4748 (lambda (x) 4678 (lambda (x)
4749 (format-spec x `((?u . ,(or user "root"))))) 4679 (format-spec x `((?u . ,(or user "root")))))
4750 (tramp-get-su-args 4680 (tramp-get-login-args
4751 multi-method 4681 multi-method
4752 (tramp-find-method multi-method method user host) 4682 (tramp-find-method multi-method method user host)
4753 user host)))) 4683 user host))))
4754 (found nil) 4684 (found nil)
4755 (pw nil)) 4685 (pw nil))
4949 (insert "[[Regexp `" regexp "' not found" 4879 (insert "[[Regexp `" regexp "' not found"
4950 (if timeout (format " in %d secs" timeout) "") 4880 (if timeout (format " in %d secs" timeout) "")
4951 "]]")))) 4881 "]]"))))
4952 found)) 4882 found))
4953 4883
4884 (defun tramp-wait-for-shell-prompt (proc timeout)
4885 "Wait for the shell prompt to appear from process PROC within TIMEOUT seconds.
4886 See `tramp-wait-for-regexp' for more details.
4887 Shell prompt pattern is determined by variables `shell-prompt-pattern'
4888 and `tramp-shell-prompt-pattern'."
4889 (tramp-wait-for-regexp
4890 proc timeout
4891 (format "\\(%s\\|%s\\)\\'"
4892 shell-prompt-pattern tramp-shell-prompt-pattern)))
4893
4894 (defun tramp-barf-if-no-shell-prompt (proc timeout &rest error-args)
4895 "Wait for shell prompt and barf if none appears.
4896 Looks at process PROC to see if a shell prompt appears in TIMEOUT
4897 seconds. If not, it produces an error message with the given ERROR-ARGS."
4898 (unless (tramp-wait-for-shell-prompt proc timeout)
4899 (pop-to-buffer (buffer-name))
4900 (apply 'error error-args)))
4901
4954 (defun tramp-enter-password (p prompt) 4902 (defun tramp-enter-password (p prompt)
4955 "Prompt for a password and send it to the remote end. 4903 "Prompt for a password and send it to the remote end.
4956 Uses PROMPT as a prompt and sends the password to process P." 4904 Uses PROMPT as a prompt and sends the password to process P."
4957 (let ((pw (tramp-read-passwd prompt))) 4905 (let ((pw (tramp-read-passwd prompt)))
4958 (erase-buffer) 4906 (erase-buffer)
4992 ;; Pittman reports that the unusual positioning of the single quotes 4940 ;; Pittman reports that the unusual positioning of the single quotes
4993 ;; makes it work under `rc', too. We also unset the variable $ENV 4941 ;; makes it work under `rc', too. We also unset the variable $ENV
4994 ;; because that is read by some sh implementations (eg, bash when 4942 ;; because that is read by some sh implementations (eg, bash when
4995 ;; called as sh) on startup; this way, we avoid the startup file 4943 ;; called as sh) on startup; this way, we avoid the startup file
4996 ;; clobbering $PS1. 4944 ;; clobbering $PS1.
4997 (process-send-string nil (format "exec env 'ENV=' 'PS1=$ ' %s%s" 4945 (tramp-send-command-internal
4998 (tramp-get-remote-sh 4946 multi-method method user host
4999 multi-method method user host) 4947 (format "exec env 'ENV=' 'PS1=$ ' %s"
5000 tramp-rsh-end-of-line)) 4948 (tramp-get-remote-sh multi-method method user host))
5001 (when tramp-debug-buffer 4949 (format "remote `%s' to come up"
5002 (save-excursion 4950 (tramp-get-remote-sh multi-method method user host)))
5003 (set-buffer (tramp-get-debug-buffer multi-method method user host)) 4951 (tramp-barf-if-no-shell-prompt
5004 (goto-char (point-max)) 4952 p 30
5005 (tramp-insert-with-face 4953 "Remote `%s' didn't come up. See buffer `%s' for details"
5006 'bold (format "$ exec env PS1='$ ' %s\n" 4954 (tramp-get-remote-sh multi-method method user host)
5007 (tramp-get-remote-sh multi-method method user host))))) 4955 (buffer-name))
5008 (tramp-message 9 "Waiting 30s for remote `%s' to come up..." 4956 (tramp-message 8 "Setting up remote shell environment")
5009 (tramp-get-remote-sh multi-method method user host))
5010 (unless (tramp-wait-for-regexp
5011 p 30 (format "\\(%s\\|%s\\)\\'"
5012 shell-prompt-pattern tramp-shell-prompt-pattern))
5013 (pop-to-buffer (buffer-name))
5014 (error "Remote `%s' didn't come up. See buffer `%s' for details"
5015 (tramp-get-remote-sh multi-method method user host)
5016 (buffer-name)))
5017 (tramp-message 9 "Setting up remote shell environment")
5018 (tramp-discard-garbage-erase-buffer p multi-method method user host) 4957 (tramp-discard-garbage-erase-buffer p multi-method method user host)
5019 (process-send-string 4958 (tramp-send-command-internal multi-method method user host
5020 nil (format "stty -inlcr -echo kill '^U'%s" tramp-rsh-end-of-line)) 4959 "stty -inlcr -echo kill '^U'")
5021 (unless (tramp-wait-for-regexp
5022 p 30 (format "\\(%s\\|%s\\)\\'"
5023 shell-prompt-pattern tramp-shell-prompt-pattern))
5024 (pop-to-buffer (buffer-name))
5025 (error "Couldn't `stty -echo', see buffer `%s'" (buffer-name)))
5026 (erase-buffer) 4960 (erase-buffer)
5027 (process-send-string nil (format "TERM=dumb; export TERM%s" 4961 (tramp-send-command-internal multi-method method user host
5028 tramp-rsh-end-of-line)) 4962 "TERM=dumb; export TERM")
5029 (unless (tramp-wait-for-regexp
5030 p 30 (format "\\(%s\\|%s\\)\\'"
5031 shell-prompt-pattern tramp-shell-prompt-pattern))
5032 (pop-to-buffer (buffer-name))
5033 (error "Couldn't `TERM=dumb; export TERM', see buffer `%s'" (buffer-name)))
5034 ;; Try to set up the coding system correctly. 4963 ;; Try to set up the coding system correctly.
5035 ;; CCC this can't be the right way to do it. Hm. 4964 ;; CCC this can't be the right way to do it. Hm.
5036 (save-excursion 4965 (save-excursion
5037 (erase-buffer) 4966 (erase-buffer)
5038 (tramp-message 9 "Determining coding system") 4967 (tramp-message 9 "Determining coding system")
5039 (process-send-string nil (format "echo foo ; echo bar %s" 4968 (tramp-send-command-internal multi-method method user host
5040 tramp-rsh-end-of-line)) 4969 "echo foo ; echo bar")
5041 (unless (tramp-wait-for-regexp
5042 p 30 (format "\\(%s\\|%s\\)\\'"
5043 shell-prompt-pattern tramp-shell-prompt-pattern))
5044 (pop-to-buffer (buffer-name))
5045 (error "Couldn't `echo foo; echo bar' to determine line endings'"))
5046 (goto-char (point-min)) 4970 (goto-char (point-min))
5047 (if (featurep 'mule) 4971 (if (featurep 'mule)
5048 ;; Use MULE to select the right EOL convention for communicating 4972 ;; Use MULE to select the right EOL convention for communicating
5049 ;; with the process. 4973 ;; with the process.
5050 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided))) 4974 (let* ((cs (or (process-coding-system p) (cons 'undecided 'undecided)))
5064 (when (search-forward "\r" nil t) 4988 (when (search-forward "\r" nil t)
5065 ;; We have found a ^M but cannot frob the process coding system 4989 ;; We have found a ^M but cannot frob the process coding system
5066 ;; because we're running on a non-MULE Emacs. Let's try 4990 ;; because we're running on a non-MULE Emacs. Let's try
5067 ;; stty, instead. 4991 ;; stty, instead.
5068 (tramp-message 9 "Trying `stty -onlcr'") 4992 (tramp-message 9 "Trying `stty -onlcr'")
5069 (process-send-string nil (format "stty -onlcr%s" tramp-rsh-end-of-line)) 4993 (tramp-send-command-internal multi-method method user host
5070 (unless (tramp-wait-for-regexp 4994 "stty -onlcr"))))
5071 p 30 (format "\\(%s\\|%s\\)\\'"
5072 shell-prompt-pattern tramp-shell-prompt-pattern))
5073 (pop-to-buffer (buffer-name))
5074 (error "Couldn't `stty -onlcr', see buffer `%s'" (buffer-name))))))
5075 (erase-buffer) 4995 (erase-buffer)
5076 (tramp-message 4996 (tramp-message
5077 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'") 4997 9 "Waiting 30s for `HISTFILE=$HOME/.tramp_history; HISTSIZE=1'")
5078 (process-send-string 4998 (tramp-send-command-internal multi-method method user host
5079 nil (format "HISTFILE=$HOME/.tramp_history; HISTSIZE=1%s" 4999 "HISTFILE=$HOME/.tramp_history; HISTSIZE=1")
5080 tramp-rsh-end-of-line))
5081 (unless (tramp-wait-for-regexp
5082 p 30 (format "\\(%s\\|%s\\)\\'"
5083 shell-prompt-pattern tramp-shell-prompt-pattern))
5084 (pop-to-buffer (buffer-name))
5085 (error (concat "Couldn't `HISTFILE=$HOME/.tramp_history; "
5086 "HISTSIZE=1', see buffer `%s'")
5087 (buffer-name)))
5088 (erase-buffer) 5000 (erase-buffer)
5089 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'") 5001 (tramp-message 9 "Waiting 30s for `set +o vi +o emacs'")
5090 (process-send-string 5002 (tramp-send-command-internal multi-method method user host
5091 nil (format "set +o vi +o emacs%s" ;mustn't `>/dev/null' with AIX? 5003 "set +o vi +o emacs")
5092 tramp-rsh-end-of-line))
5093 (unless (tramp-wait-for-regexp
5094 p 30 (format "\\(%s\\|%s\\)\\'"
5095 shell-prompt-pattern tramp-shell-prompt-pattern))
5096 (pop-to-buffer (buffer-name))
5097 (error "Couldn't `set +o vi +o emacs', see buffer `%s'"
5098 (buffer-name)))
5099 (erase-buffer) 5004 (erase-buffer)
5100 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'") 5005 (tramp-message 9 "Waiting 30s for `unset MAIL MAILCHECK MAILPATH'")
5101 (process-send-string 5006 (tramp-send-command-internal
5102 nil (format "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null%s" 5007 multi-method method user host
5103 tramp-rsh-end-of-line)) 5008 "unset MAIL MAILCHECK MAILPATH 1>/dev/null 2>/dev/null")
5104 (unless (tramp-wait-for-regexp
5105 p 30 (format "\\(%s\\|%s\\)\\'"
5106 shell-prompt-pattern tramp-shell-prompt-pattern))
5107 (pop-to-buffer (buffer-name))
5108 (error "Couldn't `unset MAIL MAILCHECK MAILPATH', see buffer `%s'"
5109 (buffer-name)))
5110 (erase-buffer) 5009 (erase-buffer)
5111 (tramp-message 9 "Waiting 30s for `unset CDPATH'") 5010 (tramp-message 9 "Waiting 30s for `unset CDPATH'")
5112 (process-send-string 5011 (tramp-send-command-internal multi-method method user host
5113 nil (format "unset CDPATH%s" tramp-rsh-end-of-line)) 5012 "unset CDPATH")
5114 (unless (tramp-wait-for-regexp
5115 p 30 (format "\\(%s\\|%s\\)\\'"
5116 shell-prompt-pattern tramp-shell-prompt-pattern))
5117 (pop-to-buffer (buffer-name))
5118 (error "Couldn't `unset CDPATH', see buffer `%s'"
5119 (buffer-name)))
5120 (erase-buffer) 5013 (erase-buffer)
5121 (tramp-message 9 "Setting shell prompt") 5014 (tramp-message 9 "Setting shell prompt")
5122 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must 5015 ;; Douglas Gray Stephens <DGrayStephens@slb.com> says that we must
5123 ;; use "\n" here, not tramp-rsh-end-of-line. We also manually frob 5016 ;; use "\n" here, not tramp-rsh-end-of-line. We also manually frob
5124 ;; the last time we sent a command, to avoid tramp-send-command to send 5017 ;; the last time we sent a command, to avoid tramp-send-command to send
5238 (concat "tramp_file_attributes () {\n" 5131 (concat "tramp_file_attributes () {\n"
5239 tramp-remote-perl 5132 tramp-remote-perl
5240 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n" 5133 " -e '" tramp-perl-file-attributes "' $1 2>/dev/null\n"
5241 "}")) 5134 "}"))
5242 (tramp-wait-for-output) 5135 (tramp-wait-for-output)
5243 (unless (tramp-get-rcp-program 5136 (unless (tramp-get-copy-program
5244 multi-method 5137 multi-method
5245 (tramp-find-method multi-method method user host) 5138 (tramp-find-method multi-method method user host)
5246 user host) 5139 user host)
5247 (tramp-message 5 "Sending the Perl `mime-encode' implementations.") 5140 (tramp-message 5 "Sending the Perl `mime-encode' implementations.")
5248 (tramp-send-string 5141 (tramp-send-string
5280 "ln" tramp-remote-path nil))) 5173 "ln" tramp-remote-path nil)))
5281 (when ln 5174 (when ln
5282 (tramp-set-connection-property "ln" ln multi-method method user host))) 5175 (tramp-set-connection-property "ln" ln multi-method method user host)))
5283 (erase-buffer) 5176 (erase-buffer)
5284 ;; Find the right encoding/decoding commands to use. 5177 ;; Find the right encoding/decoding commands to use.
5285 (unless (tramp-get-rcp-program 5178 (unless (tramp-get-copy-program
5286 multi-method 5179 multi-method
5287 (tramp-find-method multi-method method user host) 5180 (tramp-find-method multi-method method user host)
5288 user host) 5181 user host)
5289 (tramp-find-inline-encoding multi-method method user host)) 5182 (tramp-find-inline-encoding multi-method method user host))
5290 ;; If encoding/decoding command are given, test to see if they work. 5183 ;; If encoding/decoding command are given, test to see if they work.
5525 (unless noerase (erase-buffer)) 5418 (unless noerase (erase-buffer))
5526 (setq proc (get-buffer-process (current-buffer))) 5419 (setq proc (get-buffer-process (current-buffer)))
5527 (process-send-string proc 5420 (process-send-string proc
5528 (concat command tramp-rsh-end-of-line)))) 5421 (concat command tramp-rsh-end-of-line))))
5529 5422
5423 (defun tramp-send-command-internal
5424 (multi-method method user host command &optional msg)
5425 "Send command to remote host and wait for success.
5426 Sends COMMAND, then waits 30 seconds for shell prompt."
5427 (tramp-send-command multi-method method user host command t t)
5428 (when msg
5429 (tramp-message 9 "Waiting 30s for %s..." msg))
5430 (tramp-barf-if-no-shell-prompt
5431 nil 30
5432 "Couldn't `%s', see buffer `%s'" command (buffer-name)))
5433
5530 (defun tramp-wait-for-output (&optional timeout) 5434 (defun tramp-wait-for-output (&optional timeout)
5531 "Wait for output from remote rsh command." 5435 "Wait for output from remote rsh command."
5532 (let ((proc (get-buffer-process (current-buffer))) 5436 (let ((proc (get-buffer-process (current-buffer)))
5533 (found nil) 5437 (found nil)
5534 (start-time (current-time)) 5438 (start-time (current-time))
5962 (setq hops (concat hops (format-spec hop-format 5866 (setq hops (concat hops (format-spec hop-format
5963 `((?m . ,m) (?u . ,u) (?h . ,h))))) 5867 `((?m . ,m) (?u . ,u) (?h . ,h)))))
5964 (incf i))) 5868 (incf i)))
5965 (concat prefix hops localname))) 5869 (concat prefix hops localname)))
5966 5870
5967 (defun tramp-make-rcp-program-file-name (user host localname) 5871 (defun tramp-make-copy-program-file-name (user host localname)
5968 "Create a file name suitable to be passed to `rcp'." 5872 "Create a file name suitable to be passed to `rcp' and workalikes."
5969 (if user 5873 (if user
5970 (format "%s@%s:%s" user host localname) 5874 (format "%s@%s:%s" user host localname)
5971 (format "%s:%s" host localname))) 5875 (format "%s:%s" host localname)))
5972 5876
5973 (defun tramp-method-out-of-band-p (multi-method method user host) 5877 (defun tramp-method-out-of-band-p (multi-method method user host)
5974 "Return t if this is an out-of-band method, nil otherwise. 5878 "Return t if this is an out-of-band method, nil otherwise.
5975 It is important to check for this condition, since it is not possible 5879 It is important to check for this condition, since it is not possible
5976 to enter a password for the `tramp-rcp-program'." 5880 to enter a password for the `tramp-copy-program'."
5977 (tramp-get-rcp-program 5881 (tramp-get-copy-program
5978 multi-method 5882 multi-method
5979 (tramp-find-method multi-method method user host) 5883 (tramp-find-method multi-method method user host)
5980 user host)) 5884 user host))
5981 5885
5982 ;; Variables local to connection. 5886 ;; Variables local to connection.
6070 (assoc (tramp-find-method multi-method method user host) 5974 (assoc (tramp-find-method multi-method method user host)
6071 tramp-methods)) 5975 tramp-methods))
6072 (error "Method `%s' didn't specify a remote shell" 5976 (error "Method `%s' didn't specify a remote shell"
6073 (or multi-method method))))) 5977 (or multi-method method)))))
6074 5978
6075 (defun tramp-get-rsh-program (multi-method method user host) 5979 (defun tramp-get-login-program (multi-method method user host)
6076 (second (or (assoc 'tramp-rsh-program 5980 (second (or (assoc 'tramp-login-program
6077 (assoc (tramp-find-method multi-method method user host) 5981 (assoc (tramp-find-method multi-method method user host)
6078 tramp-methods)) 5982 tramp-methods))
6079 (error "Method `%s' didn't specify an rsh program" 5983 (error "Method `%s' didn't specify a login program"
6080 (or multi-method method))))) 5984 (or multi-method method)))))
6081 5985
6082 (defun tramp-get-rsh-args (multi-method method user host) 5986 (defun tramp-get-login-args (multi-method method user host)
6083 (second (or (assoc 'tramp-rsh-args 5987 (second (or (assoc 'tramp-login-args
6084 (assoc (tramp-find-method multi-method method user host) 5988 (assoc (tramp-find-method multi-method method user host)
6085 tramp-methods)) 5989 tramp-methods))
6086 (error "Method `%s' didn't specify rsh args" 5990 (error "Method `%s' didn't specify login args"
6087 (or multi-method method))))) 5991 (or multi-method method)))))
6088 5992
6089 (defun tramp-get-rcp-program (multi-method method user host) 5993 (defun tramp-get-copy-program (multi-method method user host)
6090 (second (or (assoc 'tramp-rcp-program 5994 (second (or (assoc 'tramp-copy-program
6091 (assoc (tramp-find-method multi-method method user host) 5995 (assoc (tramp-find-method multi-method method user host)
6092 tramp-methods)) 5996 tramp-methods))
6093 (error "Method `%s' didn't specify an rcp program" 5997 (error "Method `%s' didn't specify a copy program"
6094 (or multi-method method))))) 5998 (or multi-method method)))))
6095 5999
6096 (defun tramp-get-rcp-args (multi-method method user host) 6000 (defun tramp-get-copy-args (multi-method method user host)
6097 (second (or (assoc 'tramp-rcp-args 6001 (second (or (assoc 'tramp-copy-args
6098 (assoc (tramp-find-method multi-method method user host) 6002 (assoc (tramp-find-method multi-method method user host)
6099 tramp-methods)) 6003 tramp-methods))
6100 (error "Method `%s' didn't specify rcp args" 6004 (error "Method `%s' didn't specify copy args"
6101 (or multi-method method))))) 6005 (or multi-method method)))))
6102 6006
6103 (defun tramp-get-rcp-keep-date-arg (multi-method method user host) 6007 (defun tramp-get-copy-keep-date-arg (multi-method method user host)
6104 (second (or (assoc 'tramp-rcp-keep-date-arg 6008 (second (or (assoc 'tramp-copy-keep-date-arg
6105 (assoc (tramp-find-method multi-method method user host) 6009 (assoc (tramp-find-method multi-method method user host)
6106 tramp-methods)) 6010 tramp-methods))
6107 (error "Method `%s' didn't specify `keep-date' arg for tramp" 6011 (error "Method `%s' didn't specify `keep-date' arg for tramp"
6108 (or multi-method method))))) 6012 (or multi-method method)))))
6109
6110 (defun tramp-get-su-program (multi-method method user host)
6111 (second (or (assoc 'tramp-su-program
6112 (assoc (tramp-find-method multi-method method user host)
6113 tramp-methods))
6114 (error "Method `%s' didn't specify a su program"
6115 (or multi-method method)))))
6116
6117 (defun tramp-get-su-args (multi-method method user host)
6118 (second (or (assoc 'tramp-su-args
6119 (assoc (tramp-find-method multi-method method user host)
6120 tramp-methods))
6121 (error "Method `%s' didn't specify su args"
6122 (or multi-method method)))))
6123
6124 (defun tramp-get-telnet-program (multi-method method user host)
6125 (second (or (assoc 'tramp-telnet-program
6126 (assoc (tramp-find-method multi-method method user host)
6127 tramp-methods))
6128 (error "Method `%s' didn't specify a telnet program"
6129 (or multi-method method)))))
6130
6131 (defun tramp-get-telnet-args (multi-method method user host)
6132 (second (or (assoc 'tramp-telnet-args
6133 (assoc (tramp-find-method multi-method method user host)
6134 tramp-methods))
6135 (error "Method `%s' didn't specify telnet args"
6136 (or multi-method method)))))
6137
6138 6013
6139 ;; Auto saving to a special directory. 6014 ;; Auto saving to a special directory.
6140 6015
6141 (defun tramp-make-auto-save-file-name (fn) 6016 (defun tramp-make-auto-save-file-name (fn)
6142 "Returns a file name in `tramp-auto-save-directory' for autosaving this file." 6017 "Returns a file name in `tramp-auto-save-directory' for autosaving this file."