I enter a chroot, source a script to initialize my git user (source init_my_chroot) and then seem to be too sensitive to getting kicked out of my chroot.

install: cannot create regular file ‘/path/to/testfile’: No such file or directory
make: *** [my-rule] Error 1

Is something calling exit?


set -e

main() {
  mount -t proc proc /proc || true
  mount -t devpts none /dev/pts || true
  git config alias.lg "log --oneline --decorate --all --graph"
  eval $(ssh-agent -s) && ssh-add /root/.ssh/id_rsa

main "$@"
  • does your file init_my_chroot have exit or logout anywhere in it? e.g. if it detects that make failed? – casey Sep 17 '15 at 20:18
  • @casey, added a slimmed down init script – tarabyte Sep 17 '15 at 20:26
  • set -e means that any command that gets an error triggers an exit. – Barmar Sep 17 '15 at 20:31

set -e means that the shell should exit immediately if any command exits with a non-zero status (except in some contexts that explicitly test exit status, such as the condition of an if or while).

If you want the option to be in effect only while main() is running, you can do:

set -e
main "$@"
set +e

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.