Faculty of Engineering and Mathematical Sciences 
Not logged in (login)

help4407


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).

Assignment 2 and Clarifications.
 
Options:
RSS cloud
Jump to:

Returning Multiple Values: string manipulation vs global variables vs alternatives.

1 of 390 articles shown, currently no other people reading this forum.
photo
From: Christopher M.
Date: Tue 26th May, 7:53am
Actions: 
        Login-to-reply
"Lee de Byl"                               wrote:

> Is there another mechanism I've missed for returning multiple values from functions that's 
> easy on the eyes, maintainable and efficient? What are the prevailing thoughts on global 
> variables in shell scripting achieving this, versus string processing?

Not a well supported feature (in bash).

You could have a function set multiple return values in different environment variables - similar to way 
functions receive parameters as $1, $2, ...
you could have them return values through R1, R2, ...

Related articles

Returning Multiple Values: string manipulation vs global variables vs alternatives. (all 6) RSS
├─ original   Mon 25th May, 12:09pm, Lee dB.
├─ THIS   Tue 26th May, 7:53am, Christopher M.
├─ reply 2   Tue 26th May, 1:49pm, Lee dB.  O.P.
├─ reply 3   Tue 26th May, 5:44pm, Christopher M.
├─ reply 4   Mon 1st Jun, 9:23am, Lee dB.  O.P.
└─ reply 5   Mon 1st Jun, 11:15am, Christopher M.
This Page


Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020