Skip to content

Commit

Permalink
Fix issue with not detecting home directory when .bashrc echoes (fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SchoofsKelvin committed Oct 2, 2021
1 parent 518e246 commit 860f65a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 2 additions & 4 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `
Expand Down

0 comments on commit 860f65a

Please sign in to comment.