Shahzad Shahzad - 1 year ago 149
Bash Question

Bad substitution error in bash script

I have tried a lot but couldn't get the solution out of it. I have a simple script:

#! /bin/sh
echo ${a}
echo ${b}

When executed like

$ .

it produces the correct output with no errors, but when executed like:

$ ./

it produces

./ 4: ./ Bad substitution

Any ideas why this is happening.

I was suggested to use bash mode and it works fine. But when I execute this same script through Python (changing the script header to bash), I am getting the same error.

I'm calling it from Python as:

import os
os.system(". ./")

Answer Source

Try using:


instead of

#! /bin/sh