Need help with a bash script

Discussion in 'General Off-Topic Chat' started by Naendow, May 16, 2017.

  1. Naendow
    OP

    Naendow Brick-Master

    Member
    291
    99
    Jan 4, 2016
    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:
    Warning: Spoilers inside!

    To be honest, I don't have a plan what could be wrong. Could someone here help me please? :)
     
  2. Naendow
    OP

    Naendow Brick-Master

    Member
    291
    99
    Jan 4, 2016
    Germany
    Bump