From d61f590c4c56546e7be8a71f8f0a988926d914f7 Mon Sep 17 00:00:00 2001 From: Clemens Lang Date: Thu, 14 Mar 2024 15:14:23 +0100 Subject: [PATCH] Print user@host when connecting with sftp Prior to d989217110932490ba8ce92127a9a6838878928b, using sftp user@host would print "Connected to user@host", because the 'host' variable would also contain the username. Parsing switched in the above mentioned commit for good reasons, but some users prefer to see the username if it was specified on the command line and never noticed that it did not show up when they specified a path on connection. Restore the behavior of showing the username if one was specified and make it consistent regardless of whether a path was passed on the command line or not. --- sftp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sftp.c b/sftp.c index 76ba4de373c..4eda046c5a5 100644 --- a/sftp.c +++ b/sftp.c @@ -2670,7 +2670,10 @@ main(int argc, char **argv) if (!quiet) { if (sftp_direct == NULL) - fprintf(stderr, "Connected to %s.\n", host); + if (user != NULL) + fprintf(stderr, "Connected to %s@%s.\n", user, host); + else + fprintf(stderr, "Connected to %s.\n", host); else fprintf(stderr, "Attached to %s.\n", sftp_direct); }