I have the following script:
#!/bin/bash
#
# Example script for validating SVN credentials.
var_svn_user_name=
var_svn_password=
function get_svn_credentials()
{
# First, get the credentials from the user
read -r -p "Please enter SVN User Name: " var_svn_user_name
echo -n "Please enter SVN Password: "
read -r -s var_svn_password
echo ""
echo "----------------"
echo "The SVN User Name is: ${var_svn_user_name}"
echo "The SVN User Password is: ${var_svn_password}"
# Next, validate provided credentials
echo -n "Validating credentials... "
#var_ret=$(svn list --username "${var_svn_user_name}" --password \
# "${var_svn_password}" ${var_url} ${var_cfg} ${var_opt}=${var_val} \
# --no-auth-cache --non-interactive 2>&1 | grep "Authentication failed")
if [[ $var_ret == "" ]]
then
echo 'Success'
else
echo 'Failed'
fi
}
function main()
{
# EXAMPLE Call #1
#result=$(get_svn_credentials) # FAILURE
# EXAMPLE Call #2
get_svn_credentials # SUCCESS
echo "Return value is: $result"
if [[ $var_ret == "Success" ]]
then
echo "SVN User Name and Password was validated."
else
echo "SVN User Name and Password was NOT validated."
fi
}
main "$@"
Why is it that when I comment out Example 2 and uncomment Example 1, the echoing of password does not get displayed until read executes?
I am trying to figure out how to get the return statement to work like a C function style return statement.
Would anyone be able to help with this?
returnstatement are you talking about?