From: Po Lu Date: Sun, 11 Jun 2023 09:58:47 +0000 (+0800) Subject: Update Android port X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=aad78abfd2944298715c2954614db509eec1c6b3;p=emacs.git Update Android port * lisp/net/tramp.el (tramp-encoding-shell): * lisp/obsolete/terminal.el (terminal-emulator): * lisp/term.el (term-exec-1): * lisp/textmodes/artist.el (artist-figlet-get-font-list): * src/android.c (JNICALL): Where /bin/sh was previously used, use /system/bin/sh on Android. --- diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 8c26f533bb8..7849f81aebe 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -148,7 +148,12 @@ This setting has precedence over `auto-save-file-name-transforms'." ;; Suppress `shell-file-name' for w32 systems. (defcustom tramp-encoding-shell (let (shell-file-name) - (or (tramp-compat-funcall 'w32-shell-name) "/bin/sh")) + (or (tramp-compat-funcall 'w32-shell-name) + (if (eq system-type 'android) + ;; The shell is located at /system/bin/sh on Android + ;; systems. + "/system/bin/sh" + "/bin/sh"))) "Use this program for encoding and decoding commands on the local host. This shell is used to execute the encoding and decoding command on the local host, so if you want to use \"~\" in those commands, you should diff --git a/lisp/obsolete/terminal.el b/lisp/obsolete/terminal.el index 4a2ef680b09..4e23fc3c710 100644 --- a/lisp/obsolete/terminal.el +++ b/lisp/obsolete/terminal.el @@ -1095,7 +1095,9 @@ subprocess started." (or explicit-shell-file-name (getenv "ESHELL") (getenv "SHELL") - "/bin/sh")) + (if (eq system-type 'android) + "/system/bin/sh" + "/bin/sh"))) (s (read-string (format "Run program in emulator (default %s): " default-s)))) diff --git a/lisp/term.el b/lisp/term.el index 8fad9705c98..631d22c6006 100644 --- a/lisp/term.el +++ b/lisp/term.el @@ -1726,7 +1726,12 @@ Nil if unknown.") (push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version) process-environment)) (apply #'start-process name buffer - "/bin/sh" "-c" + ;; On Android, /bin doesn't exist, and the default shell is + ;; found as /system/bin/sh. + (if (eq system-type 'android) + "/system/bin/sh" + "/bin/sh") + "-c" (format "stty -nl echo rows %d columns %d sane 2>%s;\ if [ $1 = .. ]; then shift; fi; exec \"$@\"" term-height term-width null-device) diff --git a/lisp/textmodes/artist.el b/lisp/textmodes/artist.el index e0f311552d0..08613db600c 100644 --- a/lisp/textmodes/artist.el +++ b/lisp/textmodes/artist.el @@ -2800,7 +2800,9 @@ EXTRA-ARGS for figlet, for the command line, may be specified." (defun artist-figlet-get-font-list () "Read fonts in with the shell command. Returns a list of strings." - (let* ((cmd-interpreter "/bin/sh") + (let* ((cmd-interpreter (if (eq system-type 'android) + "/system/bin/sh" + "/bin/sh")) (ls-cmd artist-figlet-list-fonts-command) (result (artist-system cmd-interpreter ls-cmd nil)) (exit-code (elt result 0)) diff --git a/src/android.c b/src/android.c index b88d072e303..4414d465107 100644 --- a/src/android.c +++ b/src/android.c @@ -2518,6 +2518,10 @@ NATIVE_NAME (initEmacs) (JNIEnv *env, jobject object, jarray argv, /* Set TMPDIR to the temporary files directory. */ setenv ("TMPDIR", android_cache_dir, 1); + /* And finally set "SHELL" to /system/bin/sh. Otherwise, some + programs will look for /bin/sh, which is problematic. */ + setenv ("SHELL", "/system/bin/sh", 1); + /* Set the cwd to that directory as well. */ if (chdir (android_files_dir)) __android_log_print (ANDROID_LOG_WARN, __func__,