#BASH weird error

25 messages · Page 1 of 1 (latest)

marsh apex
#

Sup! I'm getting weird errors while running my script, but it doesn't crash.

echo ""
echo "New dependencies updated"
echo ""
echo "Do you already have the newest .deb file? [Y/n]"
read reply
if [[$reply == 'y' || $reply == '']];
then
    echo "gg";
else
    echo "not gg";
fi
var=$(find /home/rbr4t/Downloads/ -name 'discord*.deb'| sort -n | tail -1)
echo $var
echo "File located"
echo ""
sudo apt install $var
echo ""
echo "Update complete"

And when I input y, it first of all doesn't go to the first if clause and secondly, it gives these weird two lines of error messages:

/home/rbr4t/scripts/script.sh: 10: [[y: not found
/home/rbr4t/scripts/script.sh: 10: y: not found
indigo rose
#

Try [[ $reply == 'y' || $reply == '' ]];

#

I think the space is important

marsh apex
#

nope, nothing's changed

indigo rose
#

Works on my PC 🤷‍♂️

#

If you added a space the error message must have changed

marsh apex
#

from [[y: not found -> [[: not found

indigo rose
#

How are you running it?

marsh apex
#

via alias

indigo rose
#

What's the shebang?

marsh apex
#

I can run it directly too

#

shebang?

indigo rose
#

#!/bin/bash should be the first line

marsh apex
#

#!/bin/sh

indigo rose
#

Change it to bash

marsh apex
#

not mad at all 🙂

#

👍

marsh apex
#

boom automatic discord updater is done

fallen sable
#

does read include a trailing newline?

#

oh wait, i didn't read the error message

#

oh, looks like switching to bash you got it working?

#

lol, should've read the end first

marsh apex
#

yup