Re: bash, read, and tab completion
On 11/9/05, Matt Price <[EMAIL PROTECTED]> wrote: > I want to make sure that I save my .config in a safe location. > In bash I supose this is easy: > > echo -n "Save this config as: " > read filename > cp .config $filename > > however, there's no guarantee there that I've inputted a valid path. > Is there a way to do the following while 'read'ing: > > - provide a default value (e.g. /usr/src/configs/latest-config) > - provide bash-style tab completion (so that I can be sure I'm saving > in a valid directory) "read -e filename" will use the readline library, which understands tab completion. I don't know if it's possible to set a default value. You could always go through some gymnastics: filename=/usr/src/configs/latest-config read -e -p "Save this config as: [$filename] " tmpfname [ "x$tmpfile" = "x" ] || filename=$tmpfile The last line could probably also be [ -z $tmpfile ] || filename=$tmpfile -- Michael A. Marsh http://www.umiacs.umd.edu/~mmarsh http://mamarsh.blogspot.com
bash, read, and tab completion
I'm writing a script to make sure I keep good records while experimenting with kernel parameters. between make menuconfig and make-kpkg kernel-image I want to make sure that I save my .config in a safe location. In bash I supose this is easy: echo -n "Save this config as: " read filename cp .config $filename however, there's no guarantee there that I've inputted a valid path. Is there a way to do the following while 'read'ing: - provide a default value (e.g. /usr/src/configs/latest-config) - provide bash-style tab completion (so that I can be sure I'm saving in a valid directory) I don't notice any hints in this direction in the ABS, but probably I'm just missing them. Guiadance appreciated! thanks, matt -- .''`. Matt Price : :' : Debian User `. `'` & hemi-geek `- -- if you're an evil spambot, these addresses are for you: [EMAIL PROTECTED], [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]