Skip to content

Commit 4ac52ac

Browse files
committed
fix: preserve shell wrapper condition precedence for edge case
Fixes condition ordering in extract-detach.js to match original behavior for the edge case where a shell command string is just '&'. For commands like ['/bin/sh', '-c', '&'], the shell wrapper check must run before the generic bare '&' check to correctly produce ['/bin/sh', '-c', ''] instead of ['/bin/sh', '-c'] (missing shell-string argument). This restores the precedence order from the original build-docker-exec.js and compose.js implementations.
1 parent 2e4ced4 commit 4ac52ac

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

utils/extract-detach.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,23 @@ module.exports = cmd => {
2222

2323
if (parts.length === 0) return {cmd: parts, detach};
2424

25-
// Trailing bare '&'
26-
if (parts[parts.length - 1] === '&') {
25+
// Check wrapper-specific patterns first to handle edge cases correctly
26+
if (parts[0] === '/etc/lando/exec.sh' && parts[parts.length - 1] === '&') {
27+
// Bare '&' after exec.sh wrapper
2728
parts.pop();
2829
detach = true;
29-
// '&' appended to a shell string inside a wrapper command
3030
} else if (parts[0] === '/etc/lando/exec.sh' && parts[parts.length - 1] && parts[parts.length - 1].endsWith('&')) {
31+
// '&' appended to last argument in exec.sh wrapper
3132
parts[parts.length - 1] = parts[parts.length - 1].slice(0, -1).trim();
3233
detach = true;
3334
} else if (parts[0] && parts[0].endsWith('sh') && parts[1] === '-c' && parts[2] && parts[2].endsWith('&')) {
35+
// '&' appended to shell string in sh/bash -c wrapper
3436
parts[2] = parts[2].slice(0, -1).trim();
3537
detach = true;
38+
} else if (parts[parts.length - 1] === '&') {
39+
// Trailing bare '&' for all other commands
40+
parts.pop();
41+
detach = true;
3642
}
3743

3844
return {cmd: parts, detach};

0 commit comments

Comments
 (0)