Wed 09 Nov 2005 03:59:11 AM UTC, original submission:
In the script I am writing (to rip oggs), I am trying to get data from the user.
So the first time round, it does:
PROMPT="Enter Destination Directory [$OUTPUTDIR] : "
read -er -p "$PROMPT" OUTPUTDIR
The user sees:
Enter Destination Directory [] :
At this point, the user might type:
/home/rjn/Bethoven
Now, after all the data has been input, I go round one more time, and ask the user to confirm:
PROMPT="Enter Destination Directory [$OUTPUTDIR] : "
read -er -p "$PROMPT" OUTPUTDIR
The user sees:
Enter Destination Directory [Bethoven] :
And the user must then either press enter to confirm (I treat an empty string as acceptance of the value), or type "Beethoven" to correct the entry.
What I would like to have is the initial contents of the editable line specified. Eg:
PROMPT="Enter Destination Directory [$OUTPUTDIR] : "
INITIAL_VALUE=$OUTPUTDIR
read -er -p "$PROMPT" -i "$INITIAL_VALUE" OUTPUTDIR
The user then sees:
Enter Destination Directory [Bethoven] : Bethoven
where the second "Bethoven" is already in the input buffer, ready to be edited. This makes it much quicker to correct - instead of having to type the full word, the user can simply use readline's editing facilities to correct the line.
I hope that helps - it would be really useful to me, and probably many others.
|