(lastCommand: string | null, inAltBuffer: boolean)
| 73 | } |
| 74 | |
| 75 | export function getBlockingCommand(lastCommand: string | null, inAltBuffer: boolean): string | null { |
| 76 | if (!lastCommand) return null; |
| 77 | |
| 78 | let words = lastCommand.trim().split(/\s+/); |
| 79 | if (words.length === 0) return null; |
| 80 | |
| 81 | while (words.length && WRAPPERS.includes(words[0])) { |
| 82 | words.shift(); |
| 83 | } |
| 84 | if (!words.length) return null; |
| 85 | |
| 86 | const first = words[0].split("/").pop()!; |
| 87 | const args = words.slice(1); |
| 88 | |
| 89 | if (inAltBuffer) return first; |
| 90 | |
| 91 | if (ALWAYS_BLOCK.includes(first)) return first; |
| 92 | |
| 93 | if (isAttachLike(first, args)) return first; |
| 94 | |
| 95 | if (first === "ssh" || first === "mosh" || first === "telnet" || first === "rlogin") { |
| 96 | if (isSshInteractive(args)) return first; |
| 97 | return null; |
| 98 | } |
| 99 | |
| 100 | if (first === "su" || first === "machinectl" || first === "chroot" || first === "nsenter" || first === "lxc") { |
| 101 | if (!args.length || SHELLS.includes(args[args.length - 1]?.split("/").pop() || "")) return first; |
| 102 | return null; |
| 103 | } |
| 104 | |
| 105 | if (SHELLS.includes(first)) { |
| 106 | if (looksInteractiveShellArgs(args)) return first; |
| 107 | if (isNonInteractiveShellExec(args)) return null; |
| 108 | return null; |
| 109 | } |
| 110 | |
| 111 | if (BARE_REPLS.includes(first)) { |
| 112 | if (args.length === 0) return first; |
| 113 | return null; |
| 114 | } |
| 115 | |
| 116 | return null; |
| 117 | } |
no test coverage detected