The function <tt>get_password</tt> doesn't do anything that couldn't be done without a shell function, but the result is much more readable. The function invokes the built-in command <tt>read</tt> (which reads a line of user input and saves it in one or more variables) with several options that most Bash programmers will not be familiar with. (The <tt>-r</tt> option disables a special meaning for the backslash character; the <tt>-p</tt> option causes a specified prompt, in this case <tt>Password:</tt>, to be displayed at the head of the line; and the <tt>-s</tt> option prevents the password from being displayed as the user types it in. Since the <tt>-s</tt> option also prevents the user's newline from being displayed, the <tt>echo</tt> command supplies a newline.) Additionally, the function uses the conditional expression <tt>-t 0</tt> to make sure that the script's input is coming from a terminal (a console), and not from a file or from another program that wouldn't know that a password is being requested. (This last feature is debatable; depending on the general functionality of the script, it may be better to accept a password from standard input regardless of its source, under the assumption that the source was designed with the script in mind.) The overall point is that giving sequence of commands a name — <tt>get_password</tt> — makes it much easier for a programmer to know what it does.
Within a shell function, the positional parameters (<tt>$1</tt>, <tt>$2</tt>, and so on, as well as <tt>$@</tt>, <tt>$*</tt>, and <tt>$#</tt>) refer to the arguments that the function was called with, ''not'' the arguments of the script that contains the function. If the latter are needed, then they need to be passed in explicitly to the function, using <tt>"$@"</tt>. (Even then, <tt>shift</tt> and <tt>set</tt> will only affect the positional parameters within the function, not those of the caller.)
A function call returns an exit status, just like a script (or almost any command). To explicitly specify an exit status, use the <tt>return</tt> command, which terminates the function call and returns the specified exit status. (The <tt>exit</tt> command cannot be used for this, because it would terminate the entire script, just as if it were called from outside a function.) If no exit status is specified, either because no argument is given to the <tt>return</tt> command or because the end of the function is reached without having run a <tt>return</tt> command, then the function returns the exit status of the last command that was run.