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

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

View file

@ -501,59 +501,57 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# tty="${1##/dev/}" # tty="${1##/dev/}"
# case "$_uname_s" in # case "$_uname_s" in
# *CYGWIN*) # *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 # 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() { # _ssh_or_mosh_args() {
# case "$1" in # case "$1" in
# *ssh*) # *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*) # *mosh-client*)
# args=$(printf '%s' "$1" | sed -E -e 's/.*mosh-client -# (.*)\|.*$/\1/' -e 's/-[^ ]*//g' -e 's/\d:\d//g') # 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 # ssh_only=$2
# #
# tty_info=$(_tty_info "$tty") # 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 # if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086 # # shellcheck disable=SC2086
# username=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^user / { print $2; exit }') # 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 }') # [ -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 # else
# if ! _is_enabled "$ssh_only"; then # if ! _is_enabled "$ssh_only"; then
# username="${tty_info#* }" # username=${tty_info#*:}
# username="${username%% *}" # username=${username%%:*}
# fi # fi
# fi # fi
# #
@ -590,8 +590,10 @@ run -b '[ -z "#{window_active}" ] && [ -z "#{version}" ] && tmux set display-tim
# ssh_only=$2 # ssh_only=$2
# #
# tty_info=$(_tty_info "$tty") # 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 # if [ -n "$ssh_or_mosh_args" ]; then
# # shellcheck disable=SC2086 # # shellcheck disable=SC2086
# hostname=$(ssh -G $ssh_or_mosh_args 2>/dev/null | awk '/^hostname / { print $2; exit }') # 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 # shift
# #
# tty_info=$(_tty_info "$tty") # tty_info=$(_tty_info "$tty")
# command=$(printf '%s' "$tty_info" | cut -d' ' -f3-) # command=${tty_info#*:}
# command=${command#*:}
# #
# case "$command" in # case "$command" in
# *mosh-client*) # *mosh-client*)