In my fish config, I have this little bit of logic that takes care of some command incompatibilities between OS X's bsd ls and a Debian ls:
Through some poking at a problem I was having using SCP to copy to a remote server using the same config file, I found out that something about printing from a config.fish on a remote host causes the scp transfer to fail silently.
Very strange. Why would scp do an interactive login anyways?
Well, that was my thought.
I vaguely remember some logic in a bashrc I wrote one that had a early exit if it detected it was being included non-interactively.
Nothing strange from the scp command, just the basic scp file remote:~ stuff.
scp file remote:~
This also happens with bash, in case you don't know. It's because scp is a failure that expects you to be insane (sadly). See http://www.openssh.org/faq.html#2.9. You could try moving part that outputs stuff to fish_greeting function, it's automatically ran only in interactive mode. Or checking whatever you are using following snippet.
if status --is-login
echo Hello, world!
If anything shows when you run ssh ssh-server /bin/true, something is wrong, and SCP and SFTP will break badly.
ssh ssh-server /bin/true
Technically, fish could redirect entire output of init script when running it non-interactively to /dev/null, but that would be annoying when you really would want to print something. bash doesn't do that anyway, so it has similar issues with .bashrc.
Thanks very much for the explanation GlitchMr.
(Your second sentence made me laugh.)
Indeed, thanks for the explanation and the code sample.