One hint of something to check for in __any__ shell script -
The handling of whitespace.
More correctly, the handling of the "Input Field Seperator" character(s).
Often defined in the "IFS" variable and having the default of "space, tab, new-line" characters.
I can read where G.M. has dealt with space and new-line.
Perhaps tab (\x09) needs to be dealt with also?
Since this code is a shell function, and since most shell implementations recognize a function local setting of IFS -
Perhaps adding the pair of lines:
local IFS
IFS='some character you know will never show up in the key codes'
Will aid in dealing with the whitespace issues.
One hint about re-using G.M.'s function -
It is a function.
Add your code outside to the function and call the function from your added code passing the two expected parameters.
If running this function under Bash or Bash's sh mode -
You can pass any character (except \x00) by escaping it in the call.
I.E:
getkb $(printf '%q %q', parm-1, parm-2)
That will properly escape the two parameters at the point of the call and Bash's function argument processing will un-escape them.
For other sh implementations - a bit of experimenting might be required.
|