Skip to content

Commit bb47979

Browse files
andyclaude
andcommitted
RCommand: fix bash-over-ssh's duplicate command echo with --noediting (real fix for issue #64)
Root cause, finally isolated correctly: a *previous* attempt at this fix (bracketed-paste mode aside, which was a real, separate, already- fixed bug) modified the wrong code path -- it touched echoshell, which only affects the same-domain "local shell" exp_spawnv() shortcut (used when the target machine name matches this host's own hostname, e.g. niobium), not the real-ssh path (used for anything else, e.g. localhost) where the bug actually lives. Confirmed directly side by side: the identical long-command echo test never reproduces the duplicate over the local-shell shortcut, 100% of the time over real ssh. The actual remote invocation for a real ssh connection is built separately (a fixed argv array ending in "-i", not the echoshell string), and was never touched by the earlier attempt. Disabling readline there (bash's actual flag: --noediting) is the real fix -- confirmed via 10/10 repeated live runs over a real ssh connection, each now completing a full ~20KB simulated eccejobmonitor stream cleanly (previously 100% failure, truncated after the very first read). One wrinkle found empirically: bash requires GNU long options before short options in the same invocation ("bash -i --noediting" errors with "--: invalid option"; "bash --noediting -i" is the working form) -- confirmed directly before landing the fix. Regression-tested: fileOp/cd/execbg all still pass over the same connection with this change. This should make the launcher's new "Use csh/tcsh" checkbox (added minutes earlier as a stopgap, before this fix was found) unnecessary for its original purpose, though it's harmless to leave in place as a troubleshooting toggle. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 5e26797 commit bb47979

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

‎src/comm/rcommand/RCommand.C‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,28 @@ string RCommand::shellCommand(const string& remShell, const string& machine,
379379
string echoshell = "echo +hi+ && " + locShell + " -f";
380380

381381
static const char* minl = "-l";
382-
static const char* cmd[] = {"echo", "+hi+", "&&", "", "-i", 0};
382+
// bash spawned this way (as the remote command of a real ssh session,
383+
// as opposed to the same-domain "local shell" exp_spawnv() shortcut
384+
// built from echoshell above) has a confirmed, reproducible bug:
385+
// readline duplicates a trailing fragment of a long command line's
386+
// echo a second time after the real, correct echo -- and since a
387+
// caller's command text can legitimately contain its own "did this
388+
// die" marker as a literal substring (e.g. job monitoring's "echo
389+
// eccejobmonitor_went_bye_bye"), that duplicate reads as a false
390+
// "command already finished" signal. Confirmed live, directly: the
391+
// identical test over the "local shell" shortcut (which also runs
392+
// bash, just not through ssh) never reproduces this -- so it's
393+
// specific to interactive bash under a real pty-forwarded ssh
394+
// session, not bash in general. --noediting disables readline
395+
// entirely while keeping -i (interactive: reads ~/.bashrc, sets a
396+
// default prompt, etc.) intact.
397+
// bash requires GNU long options before short options in the same
398+
// invocation ("bash -i --noediting" errors with "--: invalid option";
399+
// "bash --noediting -i" is the form that actually works) -- confirmed
400+
// directly.
401+
static const char* cmdBash[] = {"echo", "+hi+", "&&", "", "--noediting", "-i", 0};
402+
static const char* cmdOther[] = {"echo", "+hi+", "&&", "", "-i", 0};
403+
const char** cmd = (locShell == "bash") ? cmdBash : cmdOther;
383404
cmd[3] = strdup(locShell.c_str());
384405

385406
// ssh verbose flag for recognizing authentication success/failure

0 commit comments

Comments
 (0)