mirror of
1
0
Fork 0

fixed #{username} being truncated under Cygwin

This commit is contained in:
Gregory Pakosz 2020-04-26 15:56:48 +02:00
parent 74602e8d8d
commit 7a64679c2d
1 changed files with 54 additions and 51 deletions

View File

@ -501,59 +501,57 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# tty="${1##/dev/}"
# case "$_uname_s" in
# *CYGWIN*)
# cygwin=true
# ps -al | tail -n +2 | awk -v tty="$tty" '
# ((/ssh/ && !/-W/) || !/ssh/) && $5 == tty {
# user[$1] = $6; parent[$1] = $2; child[$2] = $1
# }
# END {
# for (i in parent)
# {
# j = i
# while (parent[j])
# j = parent[j]
#
# if (!(i in child) && j != 1)
# {
# file = "/proc/" i "/cmdline"; getline command < file; close(file)
# gsub(/\0/, " ", command)
# "id -un " user[i] | getline username
# print i":"username":"command
# exit
# }
# }
# }
# '
# ;;
# *)
# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk '
# NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) {
# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = substr($0,4)
# }
# END {
# for (i in parent)
# {
# j = i
# while (parent[j])
# j = parent[j]
#
# if (!(i in child) && j != 1)
# {
# print i":"user[i]":"command[i]
# exit
# }
# }
# }
# '
# ;;
# esac
#
# if [ x"$cygwin" = x"true" ]; then
# ps -af | tail -n +2 | awk -v tty="$tty" '
# ((/ssh/ && !/-W/) || !/ssh/) && $4 == tty {
# user[$2] = $1; parent[$2] = $3; child[$3] = $2
# }
# END {
# for (i in parent)
# {
# j = i
# while (parent[j])
# j = parent[j]
#
# if (!(i in child) && j != 1)
# {
# file = "/proc/" i "/cmdline"; getline command < file; close(file)
# gsub(/\0/, " ", command)
# print i, user[i], command
# exit
# }
# }
# }
# '
# else
# ps -t "$tty" -o user=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -o pid= -o ppid= -o command= | awk '
# NR > 1 && ((/ssh/ && !/-W/) || !/ssh/) {
# user[$2] = $1; parent[$2] = $3; child[$3] = $2; pid=$2; $1 = $2 = $3 = ""; command[pid] = $0
# }
# END {
# for (i in parent)
# {
# j = i
# while (parent[j])
# j = parent[j]
#
# if (!(i in child) && j != 1)
# {
# print i, user[i], command[i]
# exit
# }
# }
# }
# '
# fi
# }
#
# _ssh_or_mosh_args() {
# case "$1" in
# *ssh*)
# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = $2 = $3 = ""; print $0; exit }')
# args=$(printf '%s' "$1" | awk '/ssh/ && !/vagrant ssh/ && !/autossh/ && !/-W/ { $1 = ""; print $0; exit }')
# ;;
# *mosh-client*)
# args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g')
@ -568,8 +566,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ssh_only=$2
#
# tty_info=$(_tty_info "$tty")
# command=${tty_info#*:}
# command=${command#*:}
#
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info")
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
# if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086
# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }')
@ -577,8 +577,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# [ -z "$username" ] && username=$(ssh -T -o ControlPath=none -o ProxyCommand="sh -c 'echo %%username%% %r >&2'" $ssh_or_mosh_args 2>&1 | awk '/^%username% / { print $2; exit }')
# else
# if ! _is_enabled "$ssh_only"; then
# username="${tty_info#* }"
# username="${username%% *}"
# username=${tty_info#*:}
# username=${username%%:*}
# fi
# fi
#
@ -590,8 +590,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ssh_only=$2
#
# tty_info=$(_tty_info "$tty")
# command=${tty_info#*:}
# command=${command#*:}
#
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$tty_info")
# ssh_or_mosh_args=$(_ssh_or_mosh_args "$command")
# if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086
# hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }')
@ -677,7 +679,8 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# shift
#
# tty_info=$(_tty_info "$tty")
# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-)
# command=${tty_info#*:}
# command=${command#*:}
#
# case "$command" in
# *mosh-client*)