Fix issue with not detecting home directory when .bashrc echoes (fixes #294)

issue/311
Kelvin Schoofs 3 years ago
parent 518e246ea1
commit 860f65a34d

@ -6,6 +6,7 @@
### Fixes ### Fixes
- Fix remote `code` command (#267) not working without the filesystem already connected (#292) - 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 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 ### Changes
- Proxy hop field now actually lists all known configs to pick from, instead of "TO DO" (#290) - Proxy hop field now actually lists all known configs to pick from, instead of "TO DO" (#290)

@ -22,14 +22,12 @@ export interface Connection {
} }
async function tryGetHome(ssh: Client): Promise<string | null> { async function tryGetHome(ssh: Client): Promise<string | null> {
const exec = await toPromise<ClientChannel>(cb => ssh.exec('echo Home: ~', cb)); const exec = await toPromise<ClientChannel>(cb => ssh.exec('echo "::sshfs:home:$(echo ~)\n"', cb));
let home = ''; let home = '';
exec.stdout.on('data', (chunk: any) => home += chunk); exec.stdout.on('data', (chunk: any) => home += chunk);
await toPromise(cb => exec.on('close', cb)); await toPromise(cb => exec.on('close', cb));
if (!home) return null; if (!home) return null;
const mat = home.match(/^Home: (.*?)\r?\n?$/); return home.match(/::sshfs:home:(.*?)\n/)?.[1] || null;
if (!mat) return null;
return mat[1];
} }
const TMP_PROFILE_SCRIPT = ` const TMP_PROFILE_SCRIPT = `

Loading…
Cancel
Save