Pages

Some errors using sh instead of bash

dimanche 14 août 2016

Hello everybody,

I upgraded from Ubuntu 12.04 to 16.04, so some of my scripts in bash does NOT work, for example:

Code:

#!/bin/bash

# Some other codes

for ((offset=$thumbStart; offset<=$thumbEnd; offset+=10))
        do
        printf -v outfile "$filePNG"_"%03d.png" "$((++n))"

Output:

Code:

# sh runScript.sh 
smartCode.sh: 459: functions.sh: Syntax error: Bad for loop variable

I tried with another example, it returns the same error

Code:

#!/bin/bash

for (( i=0; i<=10; i+=2 ))
do
 echo "Welcome $i times" 
done

Using bash:

Code:

# bash test.sh 
Welcome 0 times
Welcome 2 times
Welcome 4 times
Welcome 6 times
Welcome 8 times
Welcome 10 times
But in some other scripts I've got some more errors using bash, how can I swap back using:

Code:

sh test.sh

Some info:

Code:

# lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 16.04.1 LTS
Release:    16.04
Codename:    xenial

======


# type bash
bash is /bin/bash

-========


# bash -version
GNU bash, version 4.3.46(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://ift.tt/KpOJT7;


This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Thanks in advance

Let's block ads! (Why?)



Some errors using sh instead of bash

Aucun commentaire:

Enregistrer un commentaire