Skip to content

Instantly share code, notes, and snippets.

@mitio
Created January 23, 2014 11:03
Show Gist options
  • Save mitio/8576788 to your computer and use it in GitHub Desktop.
Save mitio/8576788 to your computer and use it in GitHub Desktop.
Some tools do not load a user's environment ($HOME, $PATH, etc.) when they run commands as that user. Sometimes, though, we need that environment. This script attempts to load it properly, before executing the command passed to it as arguments.
#!/bin/sh
RUNNING_AS=`whoami`
export HOME=`getent passwd $RUNNING_AS | cut -d: -f6`
source ~/.bashrc
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment