Returning Values from Bash Functions

Bash functions, unlike functions in most programming languages do not allow you to return a value to the caller.

When a bash function ends its return value is its status: zero for success, non-zero for failure. To return values, you can set a global variable with the result, or use command substitution, or you can pass in the name of a variable to use as the result variable.

The examples below describe these different mechanisms.

read more ...


 

More related items

Returning Values from Bash Functions
Linux Journal: "Bash functions, unlike functions in most programming languages do not allow you to return a value to the caller. When a bash function ends its return value is its status: zero...

Codeception Blog: Introduction to Codeception
On the Codeception blog there's an introduction to the Codeception tool, a behavior-driven framework written in PHP (in the spirit of Behat). How often do you see PHP projects with no line...

Why We Need More Programming Languages
InfoWorld: "Whenever a new programming language is announced, a certain segment of the developer population always rolls its eyes and groans that we have quite enough to choose from already,...


 

Post new comment

The content of this field is kept private and will not be shown publicly.
computer-internet.marc8.com