Need help with a bash script

NandoLawson

Brick-Master
Member
Joined
Jan 4, 2016
Messages
736
Reaction score
388
Trophies
3
Age
26
Location
Germany
XP
4,053
Country
Germany
Hey guys

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? :)
 

Site & Scene News

New Hot Discussed User Submitted