4

It is my understanding that when invoking spawn "string command" in xmonad, the argument "string command" is actually passed to /bin/sh. Is there a way to change this behavior ?

More specifically, is it possible to make the instance of the interpreter called by spawn aware of some predefined environment variables (typically, SSH_AUTH_SOCK and SSH_AGENT_PID)? Of course, it is always possible to resort to spawn "$VARIABLE=stuff; export $VARIABLE; string command", but it bothers me that the variabe should be created and exported each time.

Hugo Raguet
  • 418
  • 3
  • 11

1 Answers1

1

Strictly answering your first question, the safeSpawn function in XMonad.Util.Run (in xmonad-contrib) will run a command without passing it to a shell.

However, that shouldn't make much of a difference as far as environment variables are concerned. In both cases, the spawned command should inherit the environment of the XMonad process (which the shell's startup/rc files could tweak in the case of spawn).

It's possible to set the environment of the started process with general Haskell facilities, e.g. System.Posix.Process.executeFile (and System.Environment.getEnvironment if you want to make a modified copy of the XMonad process' environment).

Matthias J. Sax
  • 59,682
  • 7
  • 117
  • 137
fizzie
  • 11
  • 1
  • Thanks for the information. Now, let's say I already started the process, and that I would like to pass environment variables to the "environment of the XMonad process" (if that makes senses). It seems that `System.Posix.Process.executeFile` is the right tool but can you give me a simple example of how I could use it? Suppose I created a file with `$VARIABLE=stuff; export VARIABLE` if that helps. – Hugo Raguet Oct 12 '15 at 08:42