Search code examples
bashshellherokucurly-braces

Syntax confusion in shell script to install Heroku Toolbelt, "install-ubuntu.sh"


If you open up the shell script you're told to run to install the Heroku Toolbelt in Ubuntu, which can be found here, you'll see that the basic structure of the shell script is:

#!/bin/sh
{
    SCRIPT CONTENTS HERE
}

However, I'm confused what the purpose of the the curly braces at the beginning and end of that file are for? Why is all the code contained within the braces? How does that change how the script works? What's going on?


Solution

  • It is not really serving any special purpose here other than probably an attempt to set correct exit status.

    As per man bash:

    { list; }

    list is simply executed in the current shell environment. list must be terminated with a newline or semicolon. This is known as a group command. The return status is the exit status of list.