- In which two ways can we define a function?
- name() {
} - function name {
}
- name() {
- What are some advantages of functions?
- Easy to reuse code
- Facilitates code sharing
- Abstracting complex code
- What is the difference between a globally scoped variable and a locally scoped one?
Locally scoped variables are only valid within a function, globally scoped variables can be used throughout the entire script (even in functions). - How can we set values and attributes on variables?
By using the declare command. - How can a function use arguments passed to it?
In the same way as a script can: by using $1, $#, $@, and so on. - How can we return a value from a function?
By outputting it to stdout. The command that calls the function should know to capture the output, using command substitution. - What does the source command do?
It executes commands from a file in the current shell. If the sourced...
Germany
Slovakia
Canada
Brazil
Singapore
Hungary
Philippines
Mexico
Thailand
Ukraine
Luxembourg
Estonia
Lithuania
Norway
Chile
United States
Great Britain
India
Spain
South Korea
Ecuador
Colombia
Taiwan
Switzerland
Indonesia
Cyprus
Denmark
Finland
Poland
Malta
Czechia
New Zealand
Austria
Turkey
France
Sweden
Italy
Egypt
Belgium
Portugal
Slovenia
Ireland
Romania
Greece
Argentina
Malaysia
South Africa
Netherlands
Bulgaria
Latvia
Australia
Japan
Russia