dolorosus / RaspiBackup

Backup your raspi
GNU General Public License v3.0
13 stars 3 forks source link

Syntax error: Bad for loop variable #14

Closed Vannixxo closed 4 years ago

Vannixxo commented 4 years ago

Hello! I get this error when running the script

RaspiBackup.sh: 122: RaspiBackup.sh: Syntax error: Bad for loop variable

dolorosus commented 4 years ago

ok this looks strange, so I need some more information.

Please post the output of:

uname -a bash --version ls -lisa /bin/bash

Vannixxo commented 4 years ago

Here you have it:

pi@raspberrypi:~ $ uname -a Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l GNU/Linux

pi@raspberrypi:~ $ bash --version GNU bash, version 5.0.3(1)-release (arm-unknown-linux-gnueabihf) Copyright (C) 2019 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software; you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

pi@raspberrypi:~ $ ls -lisa /bin/bash 494 904 -rwxr-xr-x 1 root root 925124 Apr 18 2019 /bin/bash

dolorosus commented 4 years ago

Stunning...

Software env looks good.

So the script seemed to be called by sh instead of bash. The shebang points to /bin/bash, but if you insist on running it with the shell (e.g. calling it with "sh RaspiBackup.sh") the shebang will not force the script to be run with bash.

Call it either with "bash RaspiBackup.sh" or simply "RaspiBackup.sh" and it will work.

Vannixxo commented 4 years ago

with bash, it goes! (without it, nope) Thanks!

dolorosus commented 4 years ago

Surprise!