help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] eval and LINENO


From: Peng Yu
Subject: Re: [Help-bash] eval and LINENO
Date: Tue, 18 Dec 2018 15:26:05 -0600

This seems to be not a problem with eval, but a problem with `$()`.

The first LINENO is 5 which is expected. The second LINENO is expected
to be 7 but it is printed as 9. Should this be considered as a bug?

$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:

set -v
echo "$(declare -p LINENO)"
echo "$(
    declare -p LINENO
)"
$ ./main.sh
echo "$(declare -p LINENO)"
declare -i LINENO="5"
echo "$(
    declare -p LINENO
)"
declare -i LINENO="9"

On Thu, Nov 15, 2018 at 2:26 PM Peng Yu <address@hidden> wrote:
>
>  Hi,
>
> For the 2nd eval in main1.sh, the LINENO is not at the actual line
> number of the eval command. This behavior is counter-intuitive. Would
> it be better to make it show the line number of the 2nd eval? Thanks.
>
> $ cat script.sh
> #!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
>
> echo "$LINENO"
>
>
> $ cat main1.sh
> #!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
>
> eval '#!/usr/bin/env bash
> # vim: set noexpandtab tabstop=2:
>
> echo "$LINENO"
>
>
> '
> eval "$(< ./script.sh)"
> echo "$LINENO"
>
> $ ./main1.sh
> 13
> 14
> 12
>
>
> --
> Regards,
> Peng



-- 
Regards,
Peng



reply via email to

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