From 860f65a34da7309d305544f21bb46d96713a233a Mon Sep 17 00:00:00 2001 From: Kelvin Schoofs Date: Sat, 2 Oct 2021 18:46:19 +0200 Subject: [PATCH] Fix issue with not detecting home directory when .bashrc echoes (fixes #294) --- CHANGELOG.md | 1 + src/connection.ts | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 139754d..cb5201f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ ### Fixes - Fix remote `code` command (#267) not working without the filesystem already connected (#292) - Fix bug with broken connections when connections are initiated by spawning named terminals +- Fix issue where `.bashrc` echoing would result in home directory detection failing (#294) ### Changes - Proxy hop field now actually lists all known configs to pick from, instead of "TO DO" (#290) diff --git a/src/connection.ts b/src/connection.ts index fbfc603..6a52090 100644 --- a/src/connection.ts +++ b/src/connection.ts @@ -22,14 +22,12 @@ export interface Connection { } async function tryGetHome(ssh: Client): Promise { - const exec = await toPromise(cb => ssh.exec('echo Home: ~', cb)); + const exec = await toPromise(cb => ssh.exec('echo "::sshfs:home:$(echo ~)\n"', cb)); let home = ''; exec.stdout.on('data', (chunk: any) => home += chunk); await toPromise(cb => exec.on('close', cb)); if (!home) return null; - const mat = home.match(/^Home: (.*?)\r?\n?$/); - if (!mat) return null; - return mat[1]; + return home.match(/::sshfs:home:(.*?)\n/)?.[1] || null; } const TMP_PROFILE_SCRIPT = `