0

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
me@vm:~$ 

Is something calling exit?

init_my_chroot:

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 "$@"
tarabyte
  • 4,296

1 Answers1

2

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
Barmar
  • 9,927