[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Question about bash read function and matching ESC



Hi,

I am trying to match the ESC key in bash. The code below works as
intended when I try to match a 'normal' key like 's' or so. But it will
not for the escape key. This makes me expect this has something to do
with the high-bit stuff, but I haven't figured out how to work around
it. Anyone have a suggestion?

if read -n 1 -s -t 3 KEY ; then
  if [ "$KEY" == '\x1B' ]; then
    echo BAILOUT: nothing done
    exit 0
  fi
  #Do something useful here...
else
  echo TIMEOUT: nothing done
  exit 0
fi

Thanks for your time.

Grx HdV





Reply to: