func_name Verified current stable Not installed? Programming

Func Name / Specify Function Return Value

Specify Function Return Value

Specifies desired return values from a function and controls flow accordingly.

$
Terminal
<func_name>() { return <exit_code>; }

When To Use

In applications that require different outcomes based on function logic and return codes.

Pro Tip

Consider using enumeration for return codes to improve code readability and maintenance.

Command Builder

Tune the command before you copy it

Back to syntax
$
Generated Command
<func_name>() { return <exit_code>; }

Anatomy of Output

Understanding the result

Function 'setReturnCode' executed, returning code 0 Return Notification

Confirms function execution and the return code.

Function completed with status: successful Completion Status

Indicates that the function has executed successfully.

Troubleshooting

Common pitfalls

Error: Return statement without function context.

Solution: Ensure the return statement is inside a defined function.

Error: Invalid exit code specified.

Solution: Confirm that the return code follows the expected range.

Error: Unreachable code detected after return statement.

Solution: Check logic flow to ensure no lines follow a return statement.

Command Breakdown

What each part is doing

<func_name>()
Base Command
The executable that performs this operation. Here it runs Func Name before the shell applies any redirect operators.
<func_name>
func name
The value supplied for func name.
<exit_code>
exit code
The value supplied for exit code.

Alternative Approaches

Comparable commands in other tools

Alternative programming tools for the same job.