ok so i don't know how the whole thing works. i'll try to find out interactively
googling job control gives me http://www.gnu.org/software/libc/manual/html_node/Job-Control.html#Job-Control and https://stackoverflow.com/questions/11821378/what-does-bashno-job-control-in-this-shell-mean
so what exactly does "shell-command-to-string" do? C-h f shell-command-to-string RET
Then I click on the link to the file to get me source code. (Ch-f = M-x describe-function)
(defun shell-command-to-string (command)
"Execute shell command COMMAND and return its output as a string."
(with-output-to-string
(with-current-buffer
standard-output
(process-file shell-file-name nil t nil shell-command-switch command))))
what is "shell-file-name", you have to check by your place but for me C-h v shell-file-name RET returns "bash". (C-h v is M-x describe-variable)
and for me shell-command-switch is "-c". So no -i be default.
[WRONG]So by default you start an interactive bash in a non interactive bash. So yeah, doesn't work. I don't know much about the whole thing so can't tell you how to fix it. Maybe changing shell-command-switch would help, I'd try that out. Maybe it opens a whole another can of worms ^^![WRONG]
edit:
well actually I was quite wrong!
bash -c "bash -ic 'll'" (with ll aliased to ls -l in .bashrc) actually works!
So I guess I'd need to know what you tried to run to test it at home :)
2>/dev/null
.2>/dev/null
.. Thanks! But why is it working?2>/dev/null
any more.. (I get output, but I also get the error message)(print (shell-command-to-string "bash -ic 'my_cmd' 2>/dev/null") (current-buffer))
.