1
0
Fork 0
mirror of synced 2024-11-17 23:15:35 -05:00

worked around termux's readlink returning /apex/com.android.runtime/bin/linker64 when reading /proc/<pid>/exe, resolves #765

see also termux-play-store/termux-issues#149
This commit is contained in:
Gregory Pakosz 2024-10-07 16:51:32 +02:00
parent 2c9ef1c51b
commit bd171fabc3

View file

@ -144,8 +144,7 @@ bind P choose-buffer # choose which buffer to paste from
# -- 8< ------------------------------------------------------------------------
%if #{==:#{TMUX_PROGRAM},}
run "exec sh -c 'TMUX_PROGRAM=\"\$(LSOF=\$(PATH=\"\$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin\" command -v lsof); \$LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e \"if (s/^n((?:.(?!dylib\$|so\$))+)\$/\\1/g && s/(?:\s+\\([^\\s]+?\\))?\$//g) { print; exit } } exit 1; {\" || readlink \"/proc/#{pid}/exe\" 2>/dev/null)\"; { [ -f \"\$TMUX_PROGRAM\" ] && [ -x \"\$TMUX_PROGRAM\" ]; } || TMUX_PROGRAM=\"\$(command -v tmux || printf tmux)\"; \"\$TMUX_PROGRAM\" -S #{socket_path} set-environment -g TMUX_PROGRAM \"\$TMUX_PROGRAM\"'"
#run 'TMUX_PROGRAM="$(LSOF=$(PATH="$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command -v lsof); $LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g && s/(?:\s+\([^\s]+?\))?$//g) { print; exit } } exit 1; {" || readlink "/proc/#{pid}/exe" 2>/dev/null)"; { [ -f "$TMUX_PROGRAM" ] && [ -x "$TMUX_PROGRAM" ]; } || TMUX_PROGRAM="$(command -v tmux || printf tmux)"; "$TMUX_PROGRAM" -S #{socket_path} set-environment -g TMUX_PROGRAM "$TMUX_PROGRAM"'
run "exec sh -c 'TMUX_PROGRAM=\"\$(LSOF=\$(PATH=\"\$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin\" command -v lsof); \$LSOF -b -w -a -d txt -p #{pid} -Fn 2>/dev/null | perl -n -e \"if (s/^n((?:.(?!dylib\$|so\$))+)\$/\\1/g && s/(?:\s+\\([^\\s]+?\\))?\$//g) { print; exit } } exit 1; {\" 2>/dev/null || readlink \"/proc/#{pid}/exe\" 2>/dev/null)\"; [ x\"\$(\"\$TMUX_PROGRAM\" display -p \"#{l:#{pid}}\" 2>/dev/null)\" = x\"#{pid}\" ] || TMUX_PROGRAM=\"\$(command -v tmux || printf tmux)\"; \"\$TMUX_PROGRAM\" -S #{socket_path} set-environment -g TMUX_PROGRAM \"\$TMUX_PROGRAM\"'"
%endif
%if #{==:#{TMUX_SOCKET},}
run "exec sh -c '\"\$TMUX_PROGRAM\" -S #{socket_path} set-environment -g TMUX_SOCKET \"#{socket_path}\"'"
@ -157,7 +156,7 @@ bind P choose-buffer # choose which buffer to paste from
run "exec sh -c '\"\$TMUX_PROGRAM\" set-environment -g TMUX_CONF_LOCAL \"\$TMUX_CONF.local\"'"
%endif
run '"$TMUX_PROGRAM" source "$TMUX_CONF_LOCAL"'
run '"$TMUX_PROGRAM" -S #{socket_path} source "$TMUX_CONF_LOCAL"'
run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# EOF
@ -189,7 +188,8 @@ run 'cut -c3- "$TMUX_CONF" | sh -s _apply_configuration'
# fi
# if [ -z "$TMUX_PROGRAM" ]; then
# TMUX_PID=$(printf '%s' "$TMUX" | cut -d, -f2)
# TMUX_PROGRAM=$(lsof -b -w -a -d txt -p "$TMUX_PID" -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g) { print; exit } } exit 1; {" || readlink "/proc/$TMUX_PID/exe" 2>/dev/null || printf tmux)
# TMUX_PROGRAM=$(lsof -b -w -a -d txt -p "$TMUX_PID" -Fn 2>/dev/null | perl -n -e "if (s/^n((?:.(?!dylib$|so$))+)$/\1/g) { print; exit } } exit 1; {" 2>/dev/null || readlink "/proc/$TMUX_PID/exe" 2>/dev/null)
# [ x"$("$TMUX_PROGRAM" -S "$TMUX_SOCKET" display -p '#{pid}' 2>/dev/null)" = x"$TMUX_PID" ] || TMUX_PROGRAM=$(command -v tmux || printf tmux)
# fi
# if [ "$TMUX_PROGRAM" = "tmux" ]; then
# tmux() {