diff options
| -rw-r--r-- | lisp/net/tramp-sh.el | 218 |
1 files changed, 117 insertions, 101 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 1ce6542d1a7..137f0857f7e 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -480,7 +480,7 @@ The string is used in `tramp-methods'.") | |||
| 480 | ;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin | 480 | ;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin |
| 481 | ;; GNU/Linux (Debian, Suse, RHEL): /bin:/usr/bin | 481 | ;; GNU/Linux (Debian, Suse, RHEL): /bin:/usr/bin |
| 482 | ;; FreeBSD, DragonFly: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"! | 482 | ;; FreeBSD, DragonFly: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"! |
| 483 | ;; Darwin: /usr/bin:/bin:/usr/sbin:/sbin | 483 | ;; FreeBSD 12.1, Darwin: /usr/bin:/bin:/usr/sbin:/sbin |
| 484 | ;; IRIX64: /usr/bin | 484 | ;; IRIX64: /usr/bin |
| 485 | ;; QNAP QTS: --- | 485 | ;; QNAP QTS: --- |
| 486 | ;; Hydra: /run/current-system/sw/bin:/bin:/usr/bin | 486 | ;; Hydra: /run/current-system/sw/bin:/bin:/usr/bin |
| @@ -595,10 +595,12 @@ rm -f %t" | |||
| 595 | "Shell function to implement `uudecode' to standard output. | 595 | "Shell function to implement `uudecode' to standard output. |
| 596 | Many systems support `uudecode -o /dev/stdout' or `uudecode -o -' | 596 | Many systems support `uudecode -o /dev/stdout' or `uudecode -o -' |
| 597 | for this or `uudecode -p', but some systems don't, and for them | 597 | for this or `uudecode -p', but some systems don't, and for them |
| 598 | we have this shell function.") | 598 | we have this shell function. |
| 599 | Format specifiers are replaced by `tramp-expand-script', percent | ||
| 600 | characters need to be doubled.") | ||
| 599 | 601 | ||
| 600 | (defconst tramp-perl-file-truename | 602 | (defconst tramp-perl-file-truename |
| 601 | "%s -e ' | 603 | "%p -e ' |
| 602 | use File::Spec; | 604 | use File::Spec; |
| 603 | use Cwd \"realpath\"; | 605 | use Cwd \"realpath\"; |
| 604 | 606 | ||
| @@ -633,14 +635,14 @@ if (!$result) { | |||
| 633 | 635 | ||
| 634 | $result =~ s/\"/\\\\\"/g; | 636 | $result =~ s/\"/\\\\\"/g; |
| 635 | print \"\\\"$result\\\"\\n\"; | 637 | print \"\\\"$result\\\"\\n\"; |
| 636 | ' \"$1\" 2>/dev/null" | 638 | ' \"$1\" %n" |
| 637 | "Perl script to produce output suitable for use with `file-truename' | 639 | "Perl script to produce output suitable for use with `file-truename' |
| 638 | on the remote file system. | 640 | on the remote file system. |
| 639 | Escape sequence %s is replaced with name of Perl binary. | 641 | Format specifiers are replaced by `tramp-expand-script', percent |
| 640 | This string is passed to `format', so percent characters need to be doubled.") | 642 | characters need to be doubled.") |
| 641 | 643 | ||
| 642 | (defconst tramp-perl-file-name-all-completions | 644 | (defconst tramp-perl-file-name-all-completions |
| 643 | "%s -e ' | 645 | "%p -e ' |
| 644 | opendir(d, $ARGV[0]) || die(\"$ARGV[0]: $!\\nfail\\n\"); | 646 | opendir(d, $ARGV[0]) || die(\"$ARGV[0]: $!\\nfail\\n\"); |
| 645 | @files = readdir(d); closedir(d); | 647 | @files = readdir(d); closedir(d); |
| 646 | foreach $f (@files) { | 648 | foreach $f (@files) { |
| @@ -652,11 +654,11 @@ foreach $f (@files) { | |||
| 652 | } | 654 | } |
| 653 | } | 655 | } |
| 654 | print \"ok\\n\" | 656 | print \"ok\\n\" |
| 655 | ' \"$1\" 2>/dev/null" | 657 | ' \"$1\" %n" |
| 656 | "Perl script to produce output suitable for use with | 658 | "Perl script to produce output suitable for use with |
| 657 | `file-name-all-completions' on the remote file system. Escape | 659 | `file-name-all-completions' on the remote file system. |
| 658 | sequence %s is replaced with name of Perl binary. This string is | 660 | Format specifiers are replaced by `tramp-expand-script', percent |
| 659 | passed to `format', so percent characters need to be doubled.") | 661 | characters need to be doubled.") |
| 660 | 662 | ||
| 661 | ;; Perl script to implement `file-attributes' in a Lisp `read'able | 663 | ;; Perl script to implement `file-attributes' in a Lisp `read'able |
| 662 | ;; output. If you are hacking on this, note that you get *no* output | 664 | ;; output. If you are hacking on this, note that you get *no* output |
| @@ -665,7 +667,7 @@ passed to `format', so percent characters need to be doubled.") | |||
| 665 | ;; The device number is returned as "-1", because there will be a virtual | 667 | ;; The device number is returned as "-1", because there will be a virtual |
| 666 | ;; device number set in `tramp-sh-handle-file-attributes'. | 668 | ;; device number set in `tramp-sh-handle-file-attributes'. |
| 667 | (defconst tramp-perl-file-attributes | 669 | (defconst tramp-perl-file-attributes |
| 668 | "%s -e ' | 670 | "%p -e ' |
| 669 | @stat = lstat($ARGV[0]); | 671 | @stat = lstat($ARGV[0]); |
| 670 | if (!@stat) { | 672 | if (!@stat) { |
| 671 | print \"nil\\n\"; | 673 | print \"nil\\n\"; |
| @@ -702,14 +704,14 @@ printf( | |||
| 702 | $stat[7], | 704 | $stat[7], |
| 703 | $stat[2], | 705 | $stat[2], |
| 704 | $stat[1] | 706 | $stat[1] |
| 705 | );' \"$1\" \"$2\" 2>/dev/null" | 707 | );' \"$1\" \"$2\" %n" |
| 706 | "Perl script to produce output suitable for use with `file-attributes' | 708 | "Perl script to produce output suitable for use with `file-attributes' |
| 707 | on the remote file system. | 709 | on the remote file system. |
| 708 | Escape sequence %s is replaced with name of Perl binary. | 710 | Format specifiers are replaced by `tramp-expand-script', percent |
| 709 | This string is passed to `format', so percent characters need to be doubled.") | 711 | characters need to be doubled.") |
| 710 | 712 | ||
| 711 | (defconst tramp-perl-directory-files-and-attributes | 713 | (defconst tramp-perl-directory-files-and-attributes |
| 712 | "%s -e ' | 714 | "%p -e ' |
| 713 | chdir($ARGV[0]) or printf(\"\\\"Cannot change to $ARGV[0]: $''!''\\\"\\n\"), exit(); | 715 | chdir($ARGV[0]) or printf(\"\\\"Cannot change to $ARGV[0]: $''!''\\\"\\n\"), exit(); |
| 714 | opendir(DIR,\".\") or printf(\"\\\"Cannot open directory $ARGV[0]: $''!''\\\"\\n\"), exit(); | 716 | opendir(DIR,\".\") or printf(\"\\\"Cannot open directory $ARGV[0]: $''!''\\\"\\n\"), exit(); |
| 715 | @list = readdir(DIR); | 717 | @list = readdir(DIR); |
| @@ -754,31 +756,31 @@ for($i = 0; $i < $n; $i++) | |||
| 754 | $stat[2], | 756 | $stat[2], |
| 755 | $stat[1]); | 757 | $stat[1]); |
| 756 | } | 758 | } |
| 757 | printf(\")\\n\");' \"$1\" \"$2\" 2>/dev/null" | 759 | printf(\")\\n\");' \"$1\" \"$2\" %n" |
| 758 | "Perl script implementing `directory-files-and-attributes' as Lisp `read'able | 760 | "Perl script implementing `directory-files-and-attributes' as Lisp `read'able |
| 759 | output. | 761 | output. |
| 760 | Escape sequence %s is replaced with name of Perl binary. | 762 | Format specifiers are replaced by `tramp-expand-script', percent |
| 761 | This string is passed to `format', so percent characters need to be doubled.") | 763 | characters need to be doubled.") |
| 762 | 764 | ||
| 763 | ;; These two use base64 encoding. | 765 | ;; These two use base64 encoding. |
| 764 | (defconst tramp-perl-encode-with-module | 766 | (defconst tramp-perl-encode-with-module |
| 765 | "%s -MMIME::Base64 -0777 -ne 'print encode_base64($_)' %n" | 767 | "%p -MMIME::Base64 -0777 -ne 'print encode_base64($_)' %n" |
| 766 | "Perl program to use for encoding a file. | 768 | "Perl program to use for encoding a file. |
| 767 | Escape sequence %s is replaced with name of Perl binary. | ||
| 768 | This string is passed to `format', so percent characters need to be doubled. | ||
| 769 | This implementation requires the MIME::Base64 Perl module to be installed | 769 | This implementation requires the MIME::Base64 Perl module to be installed |
| 770 | on the remote host.") | 770 | on the remote host. |
| 771 | Format specifiers are replaced by `tramp-expand-script', percent | ||
| 772 | characters need to be doubled.") | ||
| 771 | 773 | ||
| 772 | (defconst tramp-perl-decode-with-module | 774 | (defconst tramp-perl-decode-with-module |
| 773 | "%s -MMIME::Base64 -0777 -ne 'print decode_base64($_)' %n" | 775 | "%p -MMIME::Base64 -0777 -ne 'print decode_base64($_)' %n" |
| 774 | "Perl program to use for decoding a file. | 776 | "Perl program to use for decoding a file. |
| 775 | Escape sequence %s is replaced with name of Perl binary. | ||
| 776 | This string is passed to `format', so percent characters need to be doubled. | ||
| 777 | This implementation requires the MIME::Base64 Perl module to be installed | 777 | This implementation requires the MIME::Base64 Perl module to be installed |
| 778 | on the remote host.") | 778 | on the remote host. |
| 779 | Format specifiers are replaced by `tramp-expand-script', percent | ||
| 780 | characters need to be doubled.") | ||
| 779 | 781 | ||
| 780 | (defconst tramp-perl-encode | 782 | (defconst tramp-perl-encode |
| 781 | "%s -e ' | 783 | "%p -e ' |
| 782 | # This script contributed by Juanma Barranquero <lektu@terra.es>. | 784 | # This script contributed by Juanma Barranquero <lektu@terra.es>. |
| 783 | # Copyright (C) 2002-2020 Free Software Foundation, Inc. | 785 | # Copyright (C) 2002-2020 Free Software Foundation, Inc. |
| 784 | use strict; | 786 | use strict; |
| @@ -813,11 +815,11 @@ while (read STDIN, $data, 54) { | |||
| 813 | qq(\\n); | 815 | qq(\\n); |
| 814 | }' %n" | 816 | }' %n" |
| 815 | "Perl program to use for encoding a file. | 817 | "Perl program to use for encoding a file. |
| 816 | Escape sequence %s is replaced with name of Perl binary. | 818 | Format specifiers are replaced by `tramp-expand-script', percent |
| 817 | This string is passed to `format', so percent characters need to be doubled.") | 819 | characters need to be doubled.") |
| 818 | 820 | ||
| 819 | (defconst tramp-perl-decode | 821 | (defconst tramp-perl-decode |
| 820 | "%s -e ' | 822 | "%p -e ' |
| 821 | # This script contributed by Juanma Barranquero <lektu@terra.es>. | 823 | # This script contributed by Juanma Barranquero <lektu@terra.es>. |
| 822 | # Copyright (C) 2002-2020 Free Software Foundation, Inc. | 824 | # Copyright (C) 2002-2020 Free Software Foundation, Inc. |
| 823 | use strict; | 825 | use strict; |
| @@ -857,22 +859,25 @@ while (my $data = <STDIN>) { | |||
| 857 | last if $finished; | 859 | last if $finished; |
| 858 | }' %n" | 860 | }' %n" |
| 859 | "Perl program to use for decoding a file. | 861 | "Perl program to use for decoding a file. |
| 860 | Escape sequence %s is replaced with name of Perl binary. | 862 | Format specifiers are replaced by `tramp-expand-script', percent |
| 861 | This string is passed to `format', so percent characters need to be doubled.") | 863 | characters need to be doubled.") |
| 862 | 864 | ||
| 863 | (defconst tramp-perl-pack | 865 | (defconst tramp-perl-pack |
| 864 | "%s -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)'" | 866 | "%p -e 'binmode STDIN; binmode STDOUT; print pack(q{u*}, join q{}, <>)' %n" |
| 865 | "Perl program to use for encoding a file. | 867 | "Perl program to use for encoding a file. |
| 866 | Escape sequence %s is replaced with name of Perl binary.") | 868 | Format specifiers are replaced by `tramp-expand-script', percent |
| 869 | characters need to be doubled.") | ||
| 867 | 870 | ||
| 868 | (defconst tramp-perl-unpack | 871 | (defconst tramp-perl-unpack |
| 869 | "%s -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)'" | 872 | "%p -e 'binmode STDIN; binmode STDOUT; print unpack(q{u*}, join q{}, <>)' %n" |
| 870 | "Perl program to use for decoding a file. | 873 | "Perl program to use for decoding a file. |
| 871 | Escape sequence %s is replaced with name of Perl binary.") | 874 | Format specifiers are replaced by `tramp-expand-script', percent |
| 875 | characters need to be doubled.") | ||
| 872 | 876 | ||
| 873 | (defconst tramp-hexdump-encode "%h -v -e '16/1 \" %%02x\" \"\\n\"'" | 877 | (defconst tramp-hexdump-encode "%h -v -e '16/1 \" %%02x\" \"\\n\"'" |
| 874 | "`hexdump' program to use for encoding a file. | 878 | "`hexdump' program to use for encoding a file. |
| 875 | This string is passed to `format', so percent characters need to be doubled.") | 879 | Format specifiers are replaced by `tramp-expand-script', percent |
| 880 | characters need to be doubled.") | ||
| 876 | 881 | ||
| 877 | (defconst tramp-awk-encode | 882 | (defconst tramp-awk-encode |
| 878 | "%a '\\ | 883 | "%a '\\ |
| @@ -906,21 +911,24 @@ END { | |||
| 906 | printf tail | 911 | printf tail |
| 907 | }'" | 912 | }'" |
| 908 | "`awk' program to use for encoding a file. | 913 | "`awk' program to use for encoding a file. |
| 909 | This string is passed to `format', so percent characters need to be doubled.") | 914 | Format specifiers are replaced by `tramp-expand-script', percent |
| 915 | characters need to be doubled.") | ||
| 910 | 916 | ||
| 911 | (defconst tramp-hexdump-awk-encode | 917 | (defconst tramp-hexdump-awk-encode |
| 912 | (format "%s | %s" tramp-hexdump-encode tramp-awk-encode) | 918 | (format "%s | %s" tramp-hexdump-encode tramp-awk-encode) |
| 913 | "`hexdump' / `awk' pipe to use for encoding a file. | 919 | "`hexdump' / `awk' pipe to use for encoding a file. |
| 914 | This string is passed to `format', so percent characters need to be doubled.") | 920 | Format specifiers are replaced by `tramp-expand-script', percent |
| 921 | characters need to be doubled.") | ||
| 915 | 922 | ||
| 916 | (defconst tramp-od-encode "%o -v -t x1 -A n" | 923 | (defconst tramp-od-encode "%o -v -t x1 -A n" |
| 917 | "`od' program to use for encoding a file. | 924 | "`od' program to use for encoding a file. |
| 918 | This string is passed to `format', so percent characters need to be doubled.") | 925 | Format specifiers are replaced by `tramp-expand-script', percent |
| 926 | characters need to be doubled.") | ||
| 919 | 927 | ||
| 920 | (defconst tramp-od-awk-encode | 928 | (defconst tramp-od-awk-encode (format "%s | %s" tramp-od-encode tramp-awk-encode) |
| 921 | (format "%s | %s" tramp-od-encode tramp-awk-encode) | ||
| 922 | "`od' / `awk' pipe to use for encoding a file. | 929 | "`od' / `awk' pipe to use for encoding a file. |
| 923 | This string is passed to `format', so percent characters need to be doubled.") | 930 | Format specifiers are replaced by `tramp-expand-script', percent |
| 931 | characters need to be doubled.") | ||
| 924 | 932 | ||
| 925 | (defconst tramp-awk-decode | 933 | (defconst tramp-awk-decode |
| 926 | "%a '\\ | 934 | "%a '\\ |
| @@ -946,7 +954,8 @@ BEGIN { | |||
| 946 | } | 954 | } |
| 947 | }'" | 955 | }'" |
| 948 | "Awk program to use for decoding a file. | 956 | "Awk program to use for decoding a file. |
| 949 | This string is passed to `format', so percent characters need to be doubled.") | 957 | Format specifiers are replaced by `tramp-expand-script', percent |
| 958 | characters need to be doubled.") | ||
| 950 | 959 | ||
| 951 | (defconst tramp-vc-registered-read-file-names | 960 | (defconst tramp-vc-registered-read-file-names |
| 952 | "echo \"(\" | 961 | "echo \"(\" |
| @@ -968,7 +977,8 @@ echo \")\"" | |||
| 968 | It must be send formatted with two strings; the tests for file | 977 | It must be send formatted with two strings; the tests for file |
| 969 | existence, and file readability. Input shall be read via | 978 | existence, and file readability. Input shall be read via |
| 970 | here-document, otherwise the command could exceed maximum length | 979 | here-document, otherwise the command could exceed maximum length |
| 971 | of command line.") | 980 | of command line. |
| 981 | Format specifiers \"%s\" are replaced before the script is used.") | ||
| 972 | 982 | ||
| 973 | ;; New handlers should be added here. | 983 | ;; New handlers should be added here. |
| 974 | ;;;###tramp-autoload | 984 | ;;;###tramp-autoload |
| @@ -3296,7 +3306,9 @@ implementation will be used." | |||
| 3296 | ;; correctly. Unset `file-name-handler-alist'. | 3306 | ;; correctly. Unset `file-name-handler-alist'. |
| 3297 | ;; Otherwise, epa-file gets confused. | 3307 | ;; Otherwise, epa-file gets confused. |
| 3298 | (let (file-name-handler-alist | 3308 | (let (file-name-handler-alist |
| 3299 | (coding-system-for-write 'binary)) | 3309 | (coding-system-for-write 'binary) |
| 3310 | (default-directory | ||
| 3311 | (tramp-compat-temporary-file-directory))) | ||
| 3300 | (with-temp-file tmpfile | 3312 | (with-temp-file tmpfile |
| 3301 | (set-buffer-multibyte nil) | 3313 | (set-buffer-multibyte nil) |
| 3302 | (insert-buffer-substring (tramp-get-buffer v)) | 3314 | (insert-buffer-substring (tramp-get-buffer v)) |
| @@ -3994,6 +4006,51 @@ Fall back to normal file name handler if no Tramp handler exists." | |||
| 3994 | 4006 | ||
| 3995 | ;;; Internal Functions: | 4007 | ;;; Internal Functions: |
| 3996 | 4008 | ||
| 4009 | (defun tramp-expand-script (vec script) | ||
| 4010 | "Expand SCRIPT with remote files or commands. | ||
| 4011 | \"%a\", \"%h\", \"%o\" and \"%p\" format specifiers are replaced | ||
| 4012 | by the respective `awk', `hexdump', `od' and `perl' commands. | ||
| 4013 | \"%n\" is replaced by \"2>/dev/null\", and \"%t\" is replaced by | ||
| 4014 | a temporary file name. | ||
| 4015 | If VEC is nil, the respective local commands are used. | ||
| 4016 | If there is a format specifier which cannot be expanded, this | ||
| 4017 | function returns nil." | ||
| 4018 | (if (not (string-match-p "\\(^\\|[^%]\\)%[ahnopt]" script)) | ||
| 4019 | script | ||
| 4020 | (catch 'wont-work | ||
| 4021 | (let ((awk (when (string-match-p "\\(^\\|[^%]\\)%a" script) | ||
| 4022 | (or | ||
| 4023 | (if vec (tramp-get-remote-awk vec) (executable-find "awk")) | ||
| 4024 | (throw 'wont-work nil)))) | ||
| 4025 | (hdmp (when (string-match-p "\\(^\\|[^%]\\)%h" script) | ||
| 4026 | (or | ||
| 4027 | (if vec (tramp-get-remote-hexdump vec) | ||
| 4028 | (executable-find "hexdump")) | ||
| 4029 | (throw 'wont-work nil)))) | ||
| 4030 | (dev (when (string-match-p "\\(^\\|[^%]\\)%n" script) | ||
| 4031 | (or | ||
| 4032 | (if vec (concat "2>" (tramp-get-remote-null-device vec)) | ||
| 4033 | (if (eq system-type 'windows-nt) "" | ||
| 4034 | (concat "2>" null-device))) | ||
| 4035 | (throw 'wont-work nil)))) | ||
| 4036 | (od (when (string-match-p "\\(^\\|[^%]\\)%o" script) | ||
| 4037 | (or (if vec (tramp-get-remote-od vec) (executable-find "od")) | ||
| 4038 | (throw 'wont-work nil)))) | ||
| 4039 | (perl (when (string-match-p "\\(^\\|[^%]\\)%p" script) | ||
| 4040 | (or | ||
| 4041 | (if vec | ||
| 4042 | (tramp-get-remote-perl vec) (executable-find "perl")) | ||
| 4043 | (throw 'wont-work nil)))) | ||
| 4044 | (tmp (when (string-match-p "\\(^\\|[^%]\\)%t" script) | ||
| 4045 | (or | ||
| 4046 | (if vec | ||
| 4047 | (tramp-file-local-name (tramp-make-tramp-temp-name vec)) | ||
| 4048 | (tramp-compat-make-temp-name)) | ||
| 4049 | (throw 'wont-work nil))))) | ||
| 4050 | (format-spec | ||
| 4051 | script | ||
| 4052 | (format-spec-make ?a awk ?h hdmp ?n dev ?o od ?p perl ?t tmp)))))) | ||
| 4053 | |||
| 3997 | (defun tramp-maybe-send-script (vec script name) | 4054 | (defun tramp-maybe-send-script (vec script name) |
| 3998 | "Define in remote shell function NAME implemented as SCRIPT. | 4055 | "Define in remote shell function NAME implemented as SCRIPT. |
| 3999 | Only send the definition if it has not already been done." | 4056 | Only send the definition if it has not already been done." |
| @@ -4008,14 +4065,15 @@ Only send the definition if it has not already been done." | |||
| 4008 | ;; could result in unwanted command expansion. Avoid this. | 4065 | ;; could result in unwanted command expansion. Avoid this. |
| 4009 | (setq script (tramp-compat-string-replace | 4066 | (setq script (tramp-compat-string-replace |
| 4010 | (make-string 1 ?\t) (make-string 8 ? ) script)) | 4067 | (make-string 1 ?\t) (make-string 8 ? ) script)) |
| 4011 | ;; The script could contain a call of Perl. This is masked with `%s'. | 4068 | ;; Expand format specifiers. |
| 4012 | (when (and (string-match-p "%s" script) | 4069 | (unless (setq script (tramp-expand-script vec script)) |
| 4013 | (not (tramp-get-remote-perl vec))) | 4070 | (tramp-error |
| 4014 | (tramp-error vec 'file-error "No Perl available on remote host")) | 4071 | vec 'file-error |
| 4072 | (format "Script %s is not applicable on remote host" name))) | ||
| 4073 | ;; Send it. | ||
| 4015 | (tramp-barf-unless-okay | 4074 | (tramp-barf-unless-okay |
| 4016 | vec | 4075 | vec |
| 4017 | (format "%s () {\n%s\n}" | 4076 | (format "%s () {\n%s\n}" name script) |
| 4018 | name (format script (tramp-get-remote-perl vec))) | ||
| 4019 | "Script %s sending failed" name) | 4077 | "Script %s sending failed" name) |
| 4020 | (tramp-set-connection-property | 4078 | (tramp-set-connection-property |
| 4021 | (tramp-get-connection-process vec) "scripts" (cons name scripts)))))) | 4079 | (tramp-get-connection-process vec) "scripts" (cons name scripts)))))) |
| @@ -4523,7 +4581,7 @@ process to set up. VEC specifies the connection." | |||
| 4523 | (defconst tramp-local-coding-commands | 4581 | (defconst tramp-local-coding-commands |
| 4524 | `((b64 base64-encode-region base64-decode-region) | 4582 | `((b64 base64-encode-region base64-decode-region) |
| 4525 | (uu tramp-uuencode-region uudecode-decode-region) | 4583 | (uu tramp-uuencode-region uudecode-decode-region) |
| 4526 | (pack ,(format tramp-perl-pack "perl") ,(format tramp-perl-unpack "perl"))) | 4584 | (pack ,tramp-perl-pack ,tramp-perl-unpack)) |
| 4527 | "List of local coding commands for inline transfer. | 4585 | "List of local coding commands for inline transfer. |
| 4528 | Each item is a list that looks like this: | 4586 | Each item is a list that looks like this: |
| 4529 | 4587 | ||
| @@ -4613,6 +4671,8 @@ Goes through the list `tramp-local-coding-commands' and | |||
| 4613 | vec 5 "Checking local encoding function `%s'" loc-enc) | 4671 | vec 5 "Checking local encoding function `%s'" loc-enc) |
| 4614 | (tramp-message | 4672 | (tramp-message |
| 4615 | vec 5 "Checking local encoding command `%s' for sanity" loc-enc) | 4673 | vec 5 "Checking local encoding command `%s' for sanity" loc-enc) |
| 4674 | (unless (stringp (setq loc-enc (tramp-expand-script nil loc-enc))) | ||
| 4675 | (throw 'wont-work-local nil)) | ||
| 4616 | (unless (zerop (tramp-call-local-coding-command loc-enc nil nil)) | 4676 | (unless (zerop (tramp-call-local-coding-command loc-enc nil nil)) |
| 4617 | (throw 'wont-work-local nil))) | 4677 | (throw 'wont-work-local nil))) |
| 4618 | (if (not (stringp loc-dec)) | 4678 | (if (not (stringp loc-dec)) |
| @@ -4620,6 +4680,8 @@ Goes through the list `tramp-local-coding-commands' and | |||
| 4620 | vec 5 "Checking local decoding function `%s'" loc-dec) | 4680 | vec 5 "Checking local decoding function `%s'" loc-dec) |
| 4621 | (tramp-message | 4681 | (tramp-message |
| 4622 | vec 5 "Checking local decoding command `%s' for sanity" loc-dec) | 4682 | vec 5 "Checking local decoding command `%s' for sanity" loc-dec) |
| 4683 | (unless (stringp (setq loc-dec (tramp-expand-script nil loc-dec))) | ||
| 4684 | (throw 'wont-work-local nil)) | ||
| 4623 | (unless (zerop (tramp-call-local-coding-command loc-dec nil nil)) | 4685 | (unless (zerop (tramp-call-local-coding-command loc-dec nil nil)) |
| 4624 | (throw 'wont-work-local nil))) | 4686 | (throw 'wont-work-local nil))) |
| 4625 | ;; Search for remote coding commands with the same format | 4687 | ;; Search for remote coding commands with the same format |
| @@ -4647,35 +4709,8 @@ Goes through the list `tramp-local-coding-commands' and | |||
| 4647 | (unless (stringp rem-enc) | 4709 | (unless (stringp rem-enc) |
| 4648 | (let ((name (symbol-name rem-enc)) | 4710 | (let ((name (symbol-name rem-enc)) |
| 4649 | (value (symbol-value rem-enc))) | 4711 | (value (symbol-value rem-enc))) |
| 4650 | ;; Check if remote perl exists when necessary. | ||
| 4651 | (and (string-match-p "perl" name) | ||
| 4652 | (not (tramp-get-remote-perl vec)) | ||
| 4653 | (throw 'wont-work-remote nil)) | ||
| 4654 | ;; Check if remote awk exists when necessary. | ||
| 4655 | (and (string-match-p "\\(^\\|[^%]\\)%a" value) | ||
| 4656 | (not (tramp-get-remote-awk vec)) | ||
| 4657 | (throw 'wont-work-remote nil)) | ||
| 4658 | ;; Check if remote hexdump exists when necessary. | ||
| 4659 | (and (string-match-p "\\(^\\|[^%]\\)%h" value) | ||
| 4660 | (not (tramp-get-remote-hexdump vec)) | ||
| 4661 | (throw 'wont-work-remote nil)) | ||
| 4662 | ;; Check if remote od exists when necessary. | ||
| 4663 | (and (string-match-p "\\(^\\|[^%]\\)%o" value) | ||
| 4664 | (not (tramp-get-remote-od vec)) | ||
| 4665 | (throw 'wont-work-remote nil)) | ||
| 4666 | (while (string-match "-" name) | 4712 | (while (string-match "-" name) |
| 4667 | (setq name (replace-match "_" nil t name))) | 4713 | (setq name (replace-match "_" nil t name))) |
| 4668 | (when (string-match-p "\\(^\\|[^%]\\)%[aho]" value) | ||
| 4669 | (setq value | ||
| 4670 | (format-spec | ||
| 4671 | value | ||
| 4672 | (format-spec-make | ||
| 4673 | ?a (tramp-get-remote-awk vec) | ||
| 4674 | ?h (tramp-get-remote-hexdump vec) | ||
| 4675 | ?n (concat | ||
| 4676 | "2>" (tramp-get-remote-null-device vec)) | ||
| 4677 | ?o (tramp-get-remote-od vec))) | ||
| 4678 | value (tramp-compat-string-replace "%" "%%" value))) | ||
| 4679 | (tramp-maybe-send-script vec value name) | 4714 | (tramp-maybe-send-script vec value name) |
| 4680 | (setq rem-enc name))) | 4715 | (setq rem-enc name))) |
| 4681 | (tramp-message | 4716 | (tramp-message |
| @@ -4690,28 +4725,9 @@ Goes through the list `tramp-local-coding-commands' and | |||
| 4690 | 4725 | ||
| 4691 | (unless (stringp rem-dec) | 4726 | (unless (stringp rem-dec) |
| 4692 | (let ((name (symbol-name rem-dec)) | 4727 | (let ((name (symbol-name rem-dec)) |
| 4693 | (value (symbol-value rem-dec)) | 4728 | (value (symbol-value rem-dec))) |
| 4694 | tmpfile) | ||
| 4695 | (while (string-match "-" name) | 4729 | (while (string-match "-" name) |
| 4696 | (setq name (replace-match "_" nil t name))) | 4730 | (setq name (replace-match "_" nil t name))) |
| 4697 | (when (string-match-p "\\(^\\|[^%]\\)%[aho]" value) | ||
| 4698 | (setq value | ||
| 4699 | (format-spec | ||
| 4700 | value | ||
| 4701 | (format-spec-make | ||
| 4702 | ?a (tramp-get-remote-awk vec) | ||
| 4703 | ?h (tramp-get-remote-hexdump vec) | ||
| 4704 | ?n (concat | ||
| 4705 | "2>" (tramp-get-remote-null-device vec)) | ||
| 4706 | ?o (tramp-get-remote-od vec))) | ||
| 4707 | value (tramp-compat-string-replace "%" "%%" value))) | ||
| 4708 | (when (string-match-p "\\(^\\|[^%]\\)%t" value) | ||
| 4709 | (setq tmpfile (tramp-make-tramp-temp-name vec) | ||
| 4710 | value | ||
| 4711 | (format-spec | ||
| 4712 | value | ||
| 4713 | (format-spec-make | ||
| 4714 | ?t (tramp-file-local-name tmpfile))))) | ||
| 4715 | (tramp-maybe-send-script vec value name) | 4731 | (tramp-maybe-send-script vec value name) |
| 4716 | (setq rem-dec name))) | 4732 | (setq rem-dec name))) |
| 4717 | (tramp-message | 4733 | (tramp-message |