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
- 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)

@ -22,14 +22,12 @@ export interface Connection {
}
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 = '';
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 = `

Loading…
Cancel
Save