How to change parameter values of a function in shell script?
Hi all,
I am writing a shell script program that contains a function. I have two inquires related the function, as follows:
1- I am passing a number of parameters to a function, so is it possible to change the values of the parameters from within the function and return back to the main program for further processing?
2- Can I return a specific value from the function name, I mean by using the return keyword from inside the function to return a value to the main program
the code for example:
CODE
#! /bin/bash
function callname ()
{
echo "hello $1"
echo "hello $2"
#change the value of the first parameter for further
#processing in the main program
$1=Alaa
#the value 55 to be returned to the main program
return 55
}
name=Bassam
echo -e "$name\n"
#here the function should be lunched and the value 55 should be displayed
echo callname $name Farah
#Displaying the contents of the first paramete after it has changed from within the #function itself
echo -e "$name\n"
echo -e "End of program\n"
Regards
Bassam
|