Community
Participate
Working Groups
Remote Tools uses /bin/sh for remote execution (e.g. in KillableExecution). But it implicitly assumes that the shell is a bash/zsh shell because it uses the "declare -x" in org.eclipse.ptp.remotetools.internal.common.RemoteScript.getScriptString() (I don't see why zsh wouldn't work, but I haven't tested that it does. Declare is not supported by tcsh or dash. So those two are guaranteed not to work). I see two options - After connecting find the path to a supported shell. Thus test that /bin/sh is a bash/zsh and if not find the path to bash/zsh. If no bash/zsh is found a error has to be shown. - Or test what shell /bin/sh is and if it is not a bash/zsh replace any bash specific commands with the correct commands for dash/tcsh/... The 2nd has the advantage that it would work on machines without bash. The disadvantage is that all script commands have to be tested for all shells. I think this is a maintenance nightmare. Because bash is as far as I know very widely available I would favor option 1.
Created attachment 184358 [details] environment patch
Another alternative would be to remove the dependency on the shell at all. I noticed that ChannelSession provides a setEnv method that could be used instead. Can you see if this patch works for you?
Great! This makes it work for dash on Ubuntu. org.eclipse.ptp.remotetools.internal.ssh.ControlChannel.open(IProgressMonitor) (line 86) still uses export. Otherwise I can't find any other bash specific constructs. But I'm not sure whether there are others I have missed (and don't show up in the small test I have done with Ubuntu).
Unfortunately it looks like environment variables are disabled in sshd by default. Even when enabled, there are only a maximum of 128 vars allowed (in OpenSSH anyway). Looking at the different shells, it seems that dash, bash, zsh, ksh, and sh all support "export A=B C=D". I think the easiest option would be to use "export" instead of "declare". The only time this would fail would be if /bin/sh was a link to csh or tsch, but how likely is this?
I haven't seen any machine with csh as /bin/sh (but I don't any Unix other than Linux). But according to http://jira.atlassian.com/browse/JRA-9102 the /bin/sh used in Solaris doesn't support export A=B. But it does support A=B, and then in the next line export A.
Changed to use 'export "var=val"' for each variable in HEAD and 4.0.