The 'set' Builtin
In this lesson you will become familiar with the `set` builtin, which allows you to manipulate these options within your scripts. You will cover the 'set' builtin, what POSIX is, and some useful options to set when scripting.
How Important is this Lesson?
When using bash it is very important to understand what its options are, how to set them, and how this can affect the running of your scripts.
Setting options is not absolutely core material, but once you’ve used bash for a while, understanding them becomes important. It’s also good revision material for some of the concepts covered previously regarding exported vs. non-exported variables.
Running set
Start by running set
on its own:
set
This will produce a stream of output that represents the state of your shell. In the normal case, you will see all the variables and functions set in your environment.
But my bash man page says:
Without options, the name and value of each shell variable are displayed in a format that can be reused as input for setting or resetting the currently-set variables. Read-only variables cannot be reset. In posix mode, only shell variables are listed.
— bash man page
Note: The Portable Operating System Interface(POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems.
Can you work out from your set
output whether ...