6

I installed emacs in ubuntu (using sudo apt-get install emacs). I am havine the problem that when I try to run a shell command from within emacs (for example M-! ls) the output is preceded by this:

bash: cannot set terminal process group (-1): Invalid argument
bash: no job control in this shell

In my .emacs I have the option (setq shell-command-switch "-ic") . This is so that I can presumably use my aliases as well as commands. This has not given me issues at work and it lets me use my aliases. How can I use my aliases but avoid this problem?

Drew
  • 29,895
  • 7
  • 74
  • 104
Palace Chan
  • 8,845
  • 11
  • 41
  • 93
  • You write that you use `M-x ls` to execute a shell command but AFAIK that is not a standard command. Shell commands can be run via e.g. `M-!` or `M-x shell`. Do those work for you? – N.N. Apr 10 '13 at 07:30
  • Possible duplicate of http://stackoverflow.com/questions/11821378/what-does-bashno-job-control-in-this-shell-mean – devnull Apr 10 '13 at 08:11
  • @N.N.sorry that was a typo..I meant the regular M-! stuff which does not work. – Palace Chan Apr 10 '13 at 13:32
  • possible duplicate of [Is there a way to get my emacs to recognize my bash aliases and custom functions when I run a shell command?](http://stackoverflow.com/questions/12224909/is-there-a-way-to-get-my-emacs-to-recognize-my-bash-aliases-and-custom-functions) – UpAndAdam Sep 12 '13 at 17:01
  • What happens when you do *not* use the "-ic" switches? – halloleo Oct 10 '13 at 01:58

1 Answers1

0

I guess that by setting your shell-command-switch like that, you are executing code paths in your .profile or system profile which depend on job control in shells.

I would fix this error by defining the aliases you need in the correct code paths so that that appear in shells which are not started with -i

You could try to swap -i with --rcfile .aliases or something similar so that alias in emacs does not differ from alias in your login shells. If your .bashrc has important stuff for your work, create a file like .bashrc.emacs with the content

source .bashrc
source .aliases

and point to that file with --rcfile .bashrc.emacs in your (setq) instruction.

Where did you define your aliases? Ubuntus .bashrc reads .bash_aliases and that should happen also to non-interactive shells.

p_wiersig
  • 311
  • 2
  • 7