mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-23 04:51:16 -03:00
share/functions: fix path to /bin/sh on android
As mentioned in https://github.com/fish-shell/fish-shell/issues/12055#issuecomment-3554869126 > instances of `/bin/sh` as freestanding commands within `.fish` > files are most likely not automatically handled by `termux-exec` and > This topic is complicated by the fact that some Android ROMs _do_ > contain real `/bin/sh` files Core uses /system/bin/sh on Android. Let's do the same from script (even if /bin/sh exists), for consistency.
This commit is contained in:
@@ -42,7 +42,8 @@ if test (__fish_uname) = Darwin
|
||||
|
||||
if test $age -ge $max_age
|
||||
test -d "$dir" || mkdir -m 700 -p $dir
|
||||
/bin/sh -c '( "$@" ) >/dev/null 2>&1 </dev/null &' -- \
|
||||
set -l sh (__fish_posix_shell)
|
||||
$sh -c '( "$@" ) >/dev/null 2>&1 </dev/null &' -- \
|
||||
/usr/libexec/makewhatis -o "$whatis" \
|
||||
(/usr/bin/manpath | string split : | xargs realpath)
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ function __fish_cached --description "Cache the command output for a given amoun
|
||||
set -l cache_file (path normalize $cache_dir/$cache_key)
|
||||
set -l cache_age (path mtime --relative $cache_file)
|
||||
|
||||
set -l populate_cache /bin/sh -c "
|
||||
set -l populate_cache (__fish_posix_shell) -c "
|
||||
{
|
||||
$argv
|
||||
} >$cache_file || rm $cache_file 2>/dev/null
|
||||
|
||||
9
share/functions/__fish_posix_shell.fish
Normal file
9
share/functions/__fish_posix_shell.fish
Normal file
@@ -0,0 +1,9 @@
|
||||
# localization: skip(private)
|
||||
function __fish_posix_shell
|
||||
# NOTE: this is currently duplicated with PATH_BSHELL
|
||||
if status build-info | string match -rq '^Target( \(and host\))?: .*-android(eabi)?$'
|
||||
echo /system/bin/sh
|
||||
else
|
||||
echo /bin/sh
|
||||
end
|
||||
end
|
||||
@@ -180,7 +180,8 @@ if string match -q Darwin -- (__fish_uname) && string match -q /usr/bin/git -- (
|
||||
else
|
||||
# git is installed, but on the first run it may be very slow as xcrun needs to populate the cache.
|
||||
# Kick it off in the background to populate the cache.
|
||||
/bin/sh -c '( /usr/bin/git --version; touch /tmp/__fish_git_ready ) >/dev/null 2>&1 &'
|
||||
set -l sh (__fish_posix_shell)
|
||||
$sh -c '( /usr/bin/git --version; touch /tmp/__fish_git_ready ) >/dev/null 2>&1 &'
|
||||
function __fish_git_prompt_ready
|
||||
path is /tmp/__fish_git_ready || return 1
|
||||
# git is ready, erase the function.
|
||||
|
||||
@@ -26,7 +26,8 @@ function fish_update_completions --description "Update man-page based completion
|
||||
# Orphan the job so that it continues to run in case of an early exit (#6269)
|
||||
# Note that some distros split the manpage completion script out (#7183).
|
||||
# In that case, we silence Python's failure.
|
||||
/bin/sh -c '
|
||||
set -l sh (__fish_posix_shell)
|
||||
$sh -c '
|
||||
c=$(cat)
|
||||
( printf %s "$c" | "$@" ) >/dev/null 2>&1 &
|
||||
' -- $update_argv $argv
|
||||
|
||||
@@ -228,7 +228,8 @@ chromium-browser
|
||||
# The space before the /c is to prevent msys2 from expanding it to a path
|
||||
$fish_browser " /c" start $page_url
|
||||
else if contains -- $fish_browser[1] $graphical_browsers
|
||||
/bin/sh -c '( "$@" ) &' -- $fish_browser $page_url
|
||||
set -l sh (__fish_posix_shell)
|
||||
$sh -c '( "$@" ) &' -- $fish_browser $page_url
|
||||
else
|
||||
$fish_browser $page_url
|
||||
end
|
||||
|
||||
@@ -24,6 +24,7 @@ pub fn blocked_signals_for_job(job: &Job, sigmask: &mut libc::sigset_t) -> bool
|
||||
}
|
||||
|
||||
// Bravely define _PATH_BSHELL. On practice it's /bin/sh everywhere, except on Android.
|
||||
// NOTE: this is currently duplicated in __fish_posix_shell.
|
||||
#[cfg(not(target_os = "android"))]
|
||||
pub static PATH_BSHELL: &[u8] = b"/bin/sh\0";
|
||||
|
||||
|
||||
5
tests/checks/__fish_posix_shell.fish
Normal file
5
tests/checks/__fish_posix_shell.fish
Normal file
@@ -0,0 +1,5 @@
|
||||
# RUN: %fish %s
|
||||
|
||||
set -l sh (__fish_posix_shell)
|
||||
command -v $sh
|
||||
# CHECK: {{.*/sh}}
|
||||
Reference in New Issue
Block a user