declare can set variable attributes to functions

2016-12-30 Thread isabella parakiss
$ f () { echo hello; }; declare -fail f; declare -pf f f () { echo hello } declare -afil f=() i don't think this causes any real problem but obviously it looks wrong happens in 4.3 and 4.4 and the latest devel snapshot --- xoxo iza

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with N

2016-12-30 Thread Steve Amerige
I've updated the stackoverflow question with more info. I also tested: 1 #!/bin/bash 2 shopt -s extdebug 3 main() { 4 trap 'echo $LINENO' ERR 5 $(ex

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2016-12-30 Thread Eduardo Bustamante
On Thu, Dec 29, 2016 at 9:39 PM, Eduardo Bustamante wrote: > I'm adding the bug-bash list, since I think this is actually a bug in > the parse_comsub function, or maybe in execute_command_internal. I > haven't been able to figure it out yet. What I do know is that these > two should behave the sam

Re: [Help-bash] Bash Trap: How to Get Line Number of a Subprocess with Non-Zero Status

2016-12-30 Thread Chet Ramey
On 12/29/16 10:39 PM, Eduardo Bustamante wrote: > I'm adding the bug-bash list, since I think this is actually a bug in > the parse_comsub function, or maybe in execute_command_internal. I > haven't been able to figure it out yet. What I do know is that these > two should behave the same: > >

Bug? Explanation??

2016-12-30 Thread PePa
It seems that when piping into bash, variables have different 'retention' than functions: r=23; echo $r; echo -e "r=bc\necho $r" |bash 23 23 r(){ echo Hey;}; r; echo -e "r(){ echo Ho;}\nr" |bash Hey Ho Is this a bug, or is there a rationale? Thanks, Peter

Re: Bug? Explanation??

2016-12-30 Thread Grisha Levit
On Fri, Dec 30, 2016 at 11:03 PM, PePa wrote: r=23; echo $r; echo -e "r=bc\necho $r" |bash You need to escape the $ in the second echo statement so that $r is not evaluated to 23 before being echoed. ​

Re: Bug? Explanation??

2016-12-30 Thread Peter & Kelly Passchier
Thanks Dennis and Grisha! I understand. I had thought that every line that is piped into bash is it's own shell alignment, but I understand it's more like sourcing, so these would be more or less equivalent, right? r=23; echo $r; echo -e 'r=bc\necho $r' >r; source r r=23; echo $r; echo -e 'r=bc\

Re: Bug? Explanation??

2016-12-30 Thread Peter & Kelly Passchier
I guess they are not equivalent, piping into bash opens a subshell, and sourcing doesn't; these act differently: echo exit |bash echo exit >r; source r Hope I've gotten it right now. Thanks, Peter On 31/12/2559 11:20, Peter & Kelly Passchier wrote: > Thanks Dennis and Grisha! I understand. >

Re: Bug? Explanation??

2016-12-30 Thread Dennis Williamson
On Dec 30, 2016 11:20 PM, "Peter & Kelly Passchier" < peterke...@passchier.net> wrote: Thanks Dennis and Grisha! I understand. I had thought that every line that is piped into bash is it's own shell alignment, but I understand it's more like sourcing, so these would be more or less equivalent, ri