Skip to content

Commit c6953c3

Browse files
committed
Remove dead code for python/perl b64. Base64 encode conductor.sh when sending it
1 parent 40a645e commit c6953c3

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

utilities/it2ssh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,6 @@ if command -v base64 > /dev/null 2> /dev/null; then
3434
elif command -v b64encode > /dev/null 2> /dev/null; then
3535
base64_encode() { command b64encode - | command sed '1d;$d' | command tr -d \\n\\r; }
3636
base64_decode() { command fold -w 76 | command b64decode -r; }
37-
elif detect_python; then
38-
pybase64() { command "$python" -c "import sys, base64; getattr(sys.stdout, 'buffer', sys.stdout).write(base64.standard_b64$1(getattr(sys.stdin, 'buffer', sys.stdin).read()))"; }
39-
base64_encode() { pybase64 "encode"; }
40-
base64_decode() { pybase64 "decode"; }
41-
elif detect_perl; then
42-
base64_encode() { command "$perl" -MMIME::Base64 -0777 -ne 'print encode_base64($_)'; }
43-
base64_decode() { command "$perl" -MMIME::Base64 -ne 'print decode_base64($_)'; }
4437
else
4538
die "base64 executable not present on local host"
4639
fi
@@ -144,11 +137,12 @@ if [[ $TERM == screen* ]]; then
144137
else
145138
st='\a'
146139
fi
147-
send_conductor='printf "\033]1337;SendConductor'"$st"'"'
140+
send_conductor='printf "\033]1337;SendConductor=v=2'"$st"'"'
148141

149142
# Run a command on the remote host that instructs iTerm2 to send a script, then reads the script and executes it.
150143
# I tried many ways to concatenate s and l and this is the only one that works on both Ubuntu 18 and Ubuntu 20.
151-
sanitized="stty -echo; $send_conductor"';s="";IFS=""; while read -r l;do [ "$l" = EOF ]&&break; s=$(printf "%s\n%s" "$s" "$l"); done; unset IFS; eval "$s"'
144+
esc=$(printf "\033")
145+
sanitized="stty -echo; $send_conductor"';s="";IFS=""; while read -r l;do echo "$l" >> /tmp/l; [ "$l" = "'$esc'" ]&&break; s=$(printf "%s\n%s" "$s" "$l"); done; unset IFS; s=$(echo "$s" | { command -v base64 > /dev/null 2> /dev/null && command base64 -d || { command -v b64encode > /dev/null 2> /dev/null && command fold -w 76 | command b64decode -r; } || echo "echo base64 not available on remote host"; }); eval "$s"'
152146

153147
# If ssh gets a signal, let it2ssh keep running.
154148
set +e

0 commit comments

Comments
 (0)