Re: Light weight support for JSON

2022-08-31 Thread Robert E. Griffith
I am on vacation and just skimmed this long thread so I might have missed some of the context but I wanted throw out that I recently wrote a loadable plugin that among other things, can convert JSON to and from bash arrays. Anyone interested can check it out at these git repos. https://github

Re: return exit code in EXIT trap

2022-08-08 Thread Robert E. Griffith
On 8/8/22 16:38, Robert Elz wrote: There's no need for anything to make that work, when the trap action starts running $? is set to whatever it was just previously, and the code there can save and/or use that value however it sees the need. Well I'll be. I had to write a script to test it becaus

Re: return exit code in EXIT trap

2022-08-08 Thread Robert E. Griffith
Understanding now that traps are more literally like inserting an eval, what makes return in the top level trap string special is that there are two script paths behind it so its reasonable the the coder of the trap to ask from which last statement do I want to preserve the exit code. The shell

Re: return exit code in EXIT trap

2022-08-06 Thread Robert E. Griffith
On 8/6/22 14:44, Robert Elz wrote: ... bash allows a return in the trap string (not in a function called in that string) if the trap occurs while executing a function (then the return applies to that function). ... Yes! that is what I was missing.  Years ago when I wrote my debugger, I must hav

Re: return exit code in EXIT trap

2022-08-06 Thread Robert E. Griffith
Hmmm.. I just got confused when I went to do a test... $ trap 'echo hi; return' SIGUSR2 $ kill -SIGUSR2 $$ hi bash: return: can only `return' from a function or sourced script $ $ echo $BASH_VERSION 5.0.17(1)-release I also confirmed the same error in the DEBUG trap where you s

Re: return exit code in EXIT trap

2022-08-06 Thread Robert E. Griffith
On 8/5/22 21:49, Koichi Murase wrote: 2022年8月3日(水) 21:19 Robert E. Griffith : That was an interesting read. The illuminating point for me was the statement to the effect of "the POSIX specification is not meant to describe what it correct or rational, but what historically has been implem

Re: return exit code in EXIT trap

2022-08-03 Thread Robert E. Griffith
redictable. Its a bit harder for you since your users will attribute these problems to you. --BobG On 8/2/22 18:06, Koichi Murase wrote: 2022年8月3日(水) 5:57 Chet Ramey : On 8/2/22 4:18 PM, Robert E. Griffith wrote: Is there a reason why POSIX would want the return behavior to of function do

Re: return exit code in EXIT trap

2022-08-02 Thread Robert E. Griffith
https://getyarn.io/yarn-clip/cea30edb-a7a6-465b-bc51-3d53d9281447 It was worth the wait:) --BobG On 8/2/22 16:57, Chet Ramey wrote: On 8/2/22 4:18 PM, Robert E. Griffith wrote: The first (getyarn...) link renders as a blank page for me. What it is supposed to be? https://getyarn.io/yarn

Re: return exit code in EXIT trap

2022-08-02 Thread Robert E. Griffith
ote: On 8/2/22 3:38 PM, Robert E. Griffith wrote: Is it known behavior that return without a parameter will not set the exit code from the last command when called from the EXIT trap? https://getyarn.io/_nuxt/f66cb012eec875e1f9262fd77ecdf31e.svg https://lists.gnu.org/archive/html/bug-bash/2020-0

return exit code in EXIT trap

2022-08-02 Thread Robert E. Griffith
Is it known behavior that return without a parameter will not set the exit code from the last command when called from the EXIT trap? $ cat -n exitReturnBug.sh 1 #!/usr/bin/bash 2 function shouldReturnFalse() { 3 false 4

Re: functions can fully unset local vars in other scopes

2022-08-01 Thread Robert E. Griffith
I just finished reading that 2018 discussion and the current discussion. Its hard for me to understand why this is an issue. kre's use case was unset X y=$X He called it 'braindead' for it to do anything expect to assign NULL/empty to Y but I think that is far from true. If he's thinking

Re: execute_cmd.h is not included in installed headers

2022-05-02 Thread Robert E. Griffith
>> That seems reasonable. I'll add it. Cool, thanks. --BobG On 5/2/22 16:47, Chet Ramey wrote: On 5/2/22 4:03 PM, Robert E. Griffith wrote:  >> What's your use case? I have a bash script library that supports Objects and Classes in bash script. I am now writing a loa

Re: execute_cmd.h is not included in installed headers

2022-05-02 Thread Robert E. Griffith
#x27;" } declare -A spot; ConstructObject Dog spot "Spot" declare -A whiskers; ConstructObject Cat whiskers "Whiskers" $spot.speak $whiskers.speak $ bash /tmp/test.sh Spot says 'woof' Whiskers says 'meow' On 5/2/22 15

execute_cmd.h is not included in installed headers

2022-05-02 Thread Robert E. Griffith
"execute_cmd.h" is not listed in the INSTALLED_HEADERS macro which determines which headers are included for the install-headers target. Is it problematic for a loadable builtin to execute shell functions or is it maybe an oversight that that header is not included? If I build against the full

Re: Building loadable builtin

2022-04-14 Thread Robert E. Griffith
make_local_variable("this",att_nameref); this = bind_variable_value(this, pObj->vThis->name, 0); ..then in script... declare -p this ..output.. declare -- this="myObj" --BobG On 4/14/22 12:59, Jesse Hathaway wrote: On Thu, Apr 14, 2022 at 11

Building loadable builtin

2022-04-14 Thread Robert E. Griffith
I am developing a loadable builtin and I have a question about building it for distribution. I am currently building it in the "Bash-5.0 patch 17" git commit and it works fine when I run it in the bash executable built from that same commit (5.0.17(4)) but it fails when I run it in the bash fr