Skip to content
This repository was archived by the owner on Jul 6, 2019. It is now read-only.

Commit 07b7efc

Browse files
committed
fix(fallback): shells were sometimes ignored based on $SHELL
1 parent 2404420 commit 07b7efc

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

auto-fallback.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,23 @@ function __fish_command_not_found_on_interactive --on-event fish_prompt
2626
functions --erase __fish_command_not_found_on_interactive
2727
end`
2828

29-
module.exports = function autoFallback (shell) {
30-
const SHELL = process.env.SHELL || ''
31-
32-
if (shell === 'bash' || SHELL.includes('bash')) {
29+
module.exports = autoFallback
30+
function autoFallback (shell, fromEnv) {
31+
if (shell.includes('bash')) {
3332
return POSIX.replace('handler()', 'handle()')
3433
}
3534

36-
if (shell === 'zsh' || SHELL.includes('zsh')) {
35+
if (shell.includes('zsh')) {
3736
return POSIX
3837
}
3938

40-
if (shell === 'fish' || SHELL.includes('fish')) {
39+
if (shell.includes('fish')) {
4140
return FISH
4241
}
4342

43+
if (fromEnv) {
44+
return autoFallback(fromEnv)
45+
}
46+
4447
console.error('Only Bash, Zsh, and Fish shells are supported :(')
45-
process.exit(1)
4648
}

index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,13 @@ main(parseArgs())
2121
function main (argv) {
2222
const shell = argv['shell-auto-fallback']
2323
if (shell || shell === '') {
24-
console.log(autoFallback(shell))
25-
process.exit(0)
24+
const fallback = autoFallback(shell, process.env.SHELL)
25+
if (fallback) {
26+
console.log(fallback)
27+
process.exit(0)
28+
} else {
29+
process.exit(1)
30+
}
2631
}
2732

2833
if (!argv.command || !argv.package) {

0 commit comments

Comments
 (0)