Hey guys
So, I have a pretty easy bash script, that doesn't want to work.
The cursor should move around, but it does nothing. Printf is not working for some reason. If I try to use set -x, the output looks like this:
To be honest, I don't have a plan what could be wrong. Could someone here help me please?
So, I have a pretty easy bash script, that doesn't want to work.
Code:
#!/bin/bash
UP=w
DOWN=s
LEFT=a
RIGHT=d
clear
while :; do
read -s -n 1 INPUT
if [ $INPUT=$UP ]; then
printf "\033[1A"
elif [ $INPUT=$DOWN ]; then
printf "\033[1B"
elif [ $INPUT=$LEFT ]; then
printf "\033[1C"
elif [ $INPUT=$RIGHT ]; then
printf "\033[1D"
fi
done
The cursor should move around, but it does nothing. Printf is not working for some reason. If I try to use set -x, the output looks like this:
Code:
+ :
+ read -s -n 1 INPUT
+ '[' $'\E=w' ']'
+ :rintf '\033[1A'
+ read -s -n 1 INPUT
+ '[' '[=w' ']'
+ :rintf '\033[1A'
+ read -s -n 1 INPUT
+ '[' A=w ']'
+ :rintf '\033[1A'
+ read -s -n 1 INPUT
To be honest, I don't have a plan what could be wrong. Could someone here help me please?