On Sun, May 8, 2016 at 7:24 PM, Peng Yu <address@hidden> wrote:
> Hi,
>
> The following code shows that python may not work with <<-EOF
> correctly. Is there a way to only allow bash to eat the same number of
> spaces/tabs as the line where the python is being called.
>
> ~$ cat main.sh
> #!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
>
> for x in a b c
> do
> python <<-EOF
> for i in xrange(3):
> print i
>
> EOF
> done
>
> ~$ ./main.sh
> File "<stdin>", line 2
> print i
> ^
> IndentationError: expected an indented block
> File "<stdin>", line 2
> print i
> ^
> IndentationError: expected an indented block
> File "<stdin>", line 2
> print i
> ^
> IndentationError: expected an indented block
>
> --
> Regards,
> Peng
>
> When you use <<-EOF it only eats the leading TAB characters.
if you indent the herecode with tabs and the python code with spaces it
will work.