Ok, I got it sorted.
The fix that worked for me was putting all the echo lines in /etc/profile.d/vasm.sh inside
if ( tty -s ); then
which evaluates as TRUE if the standard input is a display. When in sftp, it isn't. So no echos, no error.
The saulgoode fix in the other thread didn't work for me:
if [[ ! $(/usr/bin/tty >/dev/null) ]] ; then
nor did the fix in the webpage I mentioned:
if [ -n "$TTY" ]; then
although they should all do the same, no?
Whatever, it's solved now. Thanks all for the input!
This should really be fixed in the next Vector versions.
Apparently a similar fix was applied to .bashrc in 5.9, but not to vasm.sh.