A: 

if you need to get output from function and store in variable, you just display what's in file.

open_an_editor()
{
    cat "$1"
}
smth=$(open_an_editor file.txt)
ghostdog74
+1  A: 

If the input you need is the edited file, then you obviously need to cat filename after you do the open_an_editor filename

If you actually need the output of the editor, then you need to swap stderr and stdin i.e: nano "$1" 3>&1 1>&2 2>&3

If yo need 'friendly' user input, see this question on how to use whiptail

Kimvais
Thanks a lot! What should I google to understand what exactly this swapping does? :)
Johnny Woo
The swapping is similar to `tmp = a; a = b; b = tmp;` statements to swap the values of `a` and `b`. Here, file descriptor 3 is `tmp`, and 1, 2 are `a`, `b`. 1 is stdout, 2 is stderr.
Alok
Addition to comment by @Alok - 0,1,2 are pre-defined __file descriptors__ that point to standard input, output and error (respectively) - other file descriptors are in general 'generated' by calling open() function in programming language. However, in the swapping example the fd 3 - is directed to fd 1, and hence can be used without Here's a link about them http://en.wikipedia.org/wiki/File_descriptorAs a bonus, you can see the "already in use" file descriptors in your current shell by `ls /proc/$$/fd`
Kimvais
A: 

If all you want is for a user to enter a value then read is enough:

OLDIFS="$IFS"
IFS=$'\n'
read -p "Enter a value: " -e somevar
IFS="$OLDIFS"
echo "$somevar"
Ignacio Vazquez-Abrams