Skip to content

Commit

Permalink
check shell via basename
Browse files Browse the repository at this point in the history
#refs 124
#refs 123
  • Loading branch information
mxcl committed Nov 8, 2022
1 parent d13e1e6 commit afa8559
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app.exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ async function abracadabra(opts: Args): Promise<RV> {

//FIXME putting "$@" at the end can be invalid, it really depends on the script TBH
//FIXME shouldn’t necessarily default to bash
// This is short term until a longer term fix is available through a deno library

// This is short term until a longer term fix is available through a deno library
const saferArg0 = arg0 === '.' ? 'sh' : arg0.replaceAll('../', '')

const path = Path.mktmp().join(saferArg0).write({ force: true, text: undent`
Expand Down Expand Up @@ -294,8 +294,8 @@ async function repl(installations: Installation[], env: Record<string, string>)
const shell = Deno.env.get("SHELL")?.trim() || "/bin/sh"
const cmd = [shell, '-i'] // interactive

//TODO other shells pls
if (shell == '/bin/zsh') {
//TODO other shells pls #help-wanted
if (Path.abs(shell)?.basename() == 'zsh') {
env['PS1'] = "%F{086}tea%F{reset} %~ "
cmd.push('--no-rcs', '--no-globalrcs')
}
Expand Down
9 changes: 9 additions & 0 deletions src/vendor/Path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ export default class Path {
}
}

/// returns Path | undefined rather than throwing error if Path is not absolute
static abs(input: string | Path) {
try {
return new Path(input)
} catch {
return
}
}

/**
If the path represents an actual entry that is a symlink, returns the symlink’s
absolute destination.
Expand Down

0 comments on commit afa8559

Please sign in to comment.