so I’m very new to bash and I was making an installer for build-essential and OpenSSL. The problem is that It always stops after the first exec line. Here’s my code:
#!/bin/bash
echo "Installing build-essential"
exec sudo apt-get install build-essential > /dev/null 2>&1
echo "Finished installing build-essential"
echo ""
echo "Installing OpenSSL"
exec sudo apt-get install openssl > /dev/null 2>&1
echo "Finished installing OpenSSL"
echo ""
echo "Updates complete!"
And here’s the output:
Installing build-essential
[sudo] password for matthew:
Please keep in mind that I just started a few hours ago. Sorry for the dump question.
execnever returns to the calling script. It replaces the current process with the command followingexec. Just remove theexecaltogether, and let apt-get run like any other command.Note: there are uses of
execthat do return to the calling script, such as those that only do I/O redirection.