Skip to content

Commit

Permalink
improve shell()
Browse files Browse the repository at this point in the history
  • Loading branch information
kla committed Sep 15, 2024
1 parent 7eb14f0 commit a5dc634
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,14 @@ export default class Container {
}

async shell() {
const shells = [ '/bin/bash', '/bin/sh' ]
shells.find(async (shell) => {
try {
await this.exec(shell)
return true
} catch (e) {
return false
}
})
const shells = ['/bin/zsh', '/bin/bash']
const shellCommand = `sh -c '${shells.map(shell => `[ -f ${shell} ] && exec ${shell}`).join(' || ')} || exec /bin/sh'`

try {
await this.exec(shellCommand)
} catch (e) {
console.error('Failed to start a shell:', e)
}
}

async logs(options: { follow?: boolean, tail?: number, since?: string } = {}) {
Expand Down

0 comments on commit a5dc634

Please sign in to comment.