help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] Using <<-'EOF' with python


From: Pierre Gaston
Subject: Re: [Help-bash] Using <<-'EOF' with python
Date: Sun, 8 May 2016 19:32:56 +0300

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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]