1# 2# A function that works as a front end for both stty and the `bind' 3# builtin, so the tty driver and readline see the same changes 4# 5 6# 7# Convert between the stty ^H control character form and the readline \C-H 8# form 9# 10cvt() 11{ 12 echo "$@" | cat -v | sed 's/\^/\\C-/' 13} 14 15# 16# stty front-end. Parses the argument list and creates two command strings, 17# one for stty, another for bind. 18# 19fstty() 20{ 21 local cmd="" bargs="" 22 local e 23 24 while [ $# -gt 0 ] 25 do 26 case "$1" in 27 -a) cmd="$cmd everything" 28 ;; 29 erase) shift; 30 e=$(cvt "$1") 31 cmd="$cmd erase $1" 32 bargs="$bargs '\"$e\": backward-delete-char'" 33 ;; 34 kill) shift 35 e=$(cvt "$1") 36 cmd="$cmd kill $1" 37 bargs="$bargs '\"$e\": unix-line-discard'" 38 ;; 39 werase) shift; 40 e=$(cvt "$1") 41 cmd="$cmd erase $1" 42 bargs="$bargs '\"$e\": backward-kill-word'" 43 ;; 44 lnext) shift; 45 e=$(cvt "$1") 46 cmd="$cmd erase $1" 47 bargs="$bargs '\"$e\": quoted-insert'" 48 ;; 49 *) cmd="$cmd $1" 50 ;; 51 esac 52 shift 53 done 54 55 command stty $cmd 56 if [ -n "$bargs" ]; then 57 builtin bind $bargs 58 fi 59} 60