reporting a bug

2022-12-15 Thread yair
function sa { for y in $(seq $1 $e2); do echo "echo search $y " done } bug description: asking to search from 10 to 20 got search from 1 to 10 example: source test.sh sa 10 20 echo search 1 echo search 2 echo search 3 echo search 4 echo search 5 echo sea

Re: Handling files with CRLF line ending

2022-12-06 Thread Yair Lenga
hard core developers, just devops) are tasked with transfering existing solutions to WSL. I am not aware of hard data, but I believe those are underrepresented in this forum. I admit no hard data to support any of those. On Mon, Dec 5, 2022, 15:36 Chet Ramey wrote: > On 12/3/22 8:53 AM, Yair Le

Re: Handling files with CRLF line ending

2022-12-03 Thread Yair Lenga
dules are working in Linux. They are research people, with no access to window dev boxes. I would also mention: the research people have little interest in cross-platform portability issues. Yair On Sat, Dec 3, 2022 at 8:44 AM Greg Wooledge wrote: > On Sat, Dec 03, 2022 at 05:40:02AM -0500, Ya

Handling files with CRLF line ending

2022-12-03 Thread Yair Lenga
sible to know if a specific printf/echo should produce CRLF, as it is unknown if the program that will read the data is capable of handing CRLF line ending. Feedback/comments. Yair

Re: Supporting structured data (was: Re: bug-bash Digest, Vol 238, Issue 2)

2022-09-07 Thread Yair Lenga
hset var.{complex.$x}=value Are ok. Does not have to be hset - just borrowed it from redis. :-). Having a separate command can simplify implementation - less risk to break existing code. Yair Sent from my iPad > On Sep 7, 2022, at 3:19 AM, Martin D Kealey wrote: > > So may I

Re: Supporting structured data (was: Re: bug-bash Digest, Vol 238, Issue 2)

2022-09-07 Thread Yair Lenga
numeric context Did I get it right ? Yair On Wed, Sep 7, 2022 at 3:19 AM Martin D Kealey wrote: > Some things do indeed come down to personal preference, where there are no > right answers. Then Chet or his successor gets to pick. > > Keep in mind that most or all of my suggestions

Re: bug-bash Digest, Vol 238, Issue 2

2022-09-05 Thread Yair Lenga
even if it will be able to support '.' in the key. Needless to say - those are my own preferences. There is NO right answer here. Yair On Mon, Sep 5, 2022 at 4:15 AM Martin D Kealey wrote: > Rather than var[i1.i2.i3] I suggest a C-like var[i1][i2][i3] as that > avoids ambig

Re: bug-bash Digest, Vol 238, Issue 2

2022-09-04 Thread Yair Lenga
l [-v var] h-value * readyaml var # or event var.k1 To summarize: * Using '.' to identify the hierarchy of the h-data - extension to bash syntax. * Allow setting a "node" to new value, or new sub-document - may be extension * Converters to/from standard

Re: Light weight support for JSON

2022-08-28 Thread Yair Lenga
d expect such an > external tool to have and many many more. interfacing from curl to jq to > bash is something i do on a near daily basis. > > https://stedolan.github.io/jq/ > > On Sun, Aug 28, 2022, 09:25 Yair Lenga wrote: > >> Hi, >> >> Over the last few year

Re: Light weight support for JSON

2022-08-28 Thread Yair Lenga
tion have support to ensure correctness. will be nice to have the same - it will make bash more useful for the proper use cases. Having them as a loadable extension seems like a good practical solution. They do not have to be "built-in". Yair On Sun, Aug 28, 2022 at 2:11 PM Lawrence Veláz

Re: bug-bash Digest, Vol 237, Issue 30

2022-08-28 Thread Yair Lenga
ease edit your Subject line so it is more specific > than "Re: Contents of bug-bash digest..." > > > Today's Topics: > >1. Bash Coding style - Adopting C99 declarations (Yair Lenga) >2. Re: Light weight support for JSON (Yair Lenga) >3. Re: Bash Coding style - Adop

Re: Light weight support for JSON

2022-08-28 Thread Yair Lenga
w7 Ratchev wrote: > > > On Sun, Aug 28, 2022, 15:46 Yair Lenga wrote: > >> Sorry for not being clear. I'm looking for feedback. The solution that I >> have is using python to read the JSON, and generate the commands to build >> the associative array. Will have to

Bash Coding style - Adopting C99 declarations

2022-08-28 Thread Yair Lenga
ash compatible with C89 ? I believe some of those practices are discouraged nowadays. Yair

Re: Light weight support for JSON

2022-08-28 Thread Yair Lenga
Sorry for not being clear. I'm looking for feedback. The solution that I have is using python to read the JSON, and generate the commands to build the associative array. Will have to rewrite in "C"/submit if there is positive feedback from others readers. Yair. On Sun, Aug 28,

Light weight support for JSON

2022-08-28 Thread Yair Lenga
; is different from null. I will leave the second part to a different post, once I have some feedback. I have some prototype that i've written in python - POC - that make it possible to write things like declare -a foo curl http://www.api.com/weather/US/10013 | readjson foo printf "temperature(F) : %.1f Wind(MPH)=%d" ${foo[temp_f]}, ${foo[wind]} Yair

Re: Revisiting Error handling (errexit)

2022-07-12 Thread Yair Lenga
; is similar to 'pipefail' option - practical solution for real problems. The suggested 'errfail' in opt-in - anyone that want the old way (errexit) can use it, without saying anything. As you said, errexit was not 'good' solution when conceived, no point in trying to ma

Re: Revisiting Error handling (errexit)

2022-07-12 Thread Yair Lenga
x27;pipefail' option - practical solution for real problems. The suggested 'errfail' in opt-in - anyone that want the old way (errexit) can use it, without saying anything. As you said, errfail was not 'good' solution when conceived, no point in trying to match it (IHMO). Y

Re: Revisiting Error handling (errexit)

2022-07-09 Thread Yair Lenga
a big range of applications where bash can play an important role. For a more sophisticated environment, python, groovy, javascript or (your favorite choice) might be a better solution. Question: Out of curiosity, can you share your idea for a better solution ? Thanks for taking the time ! Yair Sen

Re: Revisiting Error handling (errexit)

2022-07-08 Thread Yair Lenga
need something like below: function copy-files { for f in f1 f2 f3 ; do cp ... && cp ... && cp ... && important-job || break done } ; And for the original function, if you do not use errfail, you will need in inject a 'return' in the RIGHT place (see belo

Re: Revisiting Error handling (errexit)

2022-07-08 Thread Yair Lenga
ntinue to the 'else' section to send the alert. Thanks for taking the time to review. Patch on bash-devel attached. For those interested: 50 lines of code, most of them are comments. 8 hours of development, including automated test script. Looking for advice on how to "official

Re: Revisiting Error handling (errexit)

2022-07-06 Thread Yair Lenga
Koichi - Thanks for highlighting this 'local -'. This feature effectively eliminates the need to support scoped 'errfail'. If it's needed in a limited context, the 'local -' can be used. Yair On Wed, Jul 6, 2022 at 1:21 PM Koichi Murase wrote: > 2022年7

Re: Revisiting Error handling (errexit)

2022-07-06 Thread Yair Lenga
m existing bash style, and is likely to cause issues for developers targeting solutions that will be somehow portable between *sh implementation. Yair. On Wed, Jul 6, 2022, 11:24 AM Martin D Kealey wrote: > Modules can have conflicting requirements of global settings that require > weir

Re: bug-bash Digest, Vol 236, Issue 8

2022-07-05 Thread Yair Lenga
t thread. Until then, Bash is my tool. As stated before, I will extend the errfail to the top level, as not everyone uses bash in the same way (with respect to (not) placing logic at the top level. Yair > > Message: 5 > Date: Wed, 6 Jul 2022 13:23:14 +1000 > From: Martin D Kealey

Re: Revisiting Error handling (errexit)

2022-07-05 Thread Yair Lenga
; cat f2 ; cat f3 ; } # 🐈🐈🐈 Catch { echo “bad cat” ; }. # 🐈‍⬛🐈‍⬛🐈‍⬛ Yair. Sent from my iPad > On Jul 6, 2022, at 2:19 AM, Lawrence Velázquez wrote: > > On Tue, Jul 5, 2022, at 6:34 PM, Yair Lenga wrote: >> I probably did not described the intended beha

Re: Revisiting Error handling (errexit)

2022-07-05 Thread Yair Lenga
Sent from my iPad > On Jul 6, 2022, at 1:07 AM, Lawrence Velázquez wrote: > > On Tue, Jul 5, 2022, at 5:18 PM, Yair Lenga wrote: >> I’m not in front of my desktop, so I can not verify behavior, but here >> is my expectation - let me know if it make sense, in the conte

Re: Revisiting Error handling (errexit)

2022-07-05 Thread Yair Lenga
I need to prepare the patch against the dev branch. Regards, Yair. Sent from my iPad > On Jul 5, 2022, at 7:27 PM, Martin D Kealey wrote: > >  > Before going to the trouble of implementing this, I think it's worth having a > discussion about the precise semantics. > >

Re: Revisiting Error handling (errexit)

2022-07-05 Thread Yair Lenga
t;connected" statements. Either create a 'main' function, or create a top level block: On Tue, Jul 5, 2022 at 12:00 AM Lawrence Velázquez wrote: > On Mon, Jul 4, 2022, at 3:55 PM, Yair Lenga wrote: > > I'm sorry - I misunderstood your original comments. I'

Re: bug-bash Digest, Vol 236, Issue 5

2022-07-04 Thread Yair Lenga
Greg, I agree with you 100%. Not trying to fix errexit behavior. The new errfail (if accepted) will provide better error handling (via opt-in) without breaking existing code. Yair. Sent from my iPad > On Jul 4, 2022, at 10:00 PM, bug-bash-requ...@gnu.org wrote: > > From: Greg Woole

Re: Revisiting Error handling (errexit)

2022-07-04 Thread Yair Lenga
Hi Lawrence, I'm sorry - I misunderstood your original comments. I'll prepare the patched version (at least, I would like to add comments before publishing...) , and share it. Where/how can I post it ? I did not see anyone else dropping source code/patches into the group ? Yair On

Re: Revisiting Error handling (errexit)

2022-07-04 Thread Yair Lenga
he code for submission/review (style, comments, test cases, ...) as needed. Was not implying for blank approval ;-) Regards, Yair On Mon, Jul 4, 2022 at 7:41 PM Lawrence Velázquez wrote: > On Mon, Jul 4, 2022, at 8:20 AM, Yair Lenga wrote: > > I was able to change Bash source and buil

Revisiting Error handling (errexit)

2022-07-04 Thread Yair Lenga
trengthen many production systems that use Bash. To emphasize, this is a minimal proposal, with no intention of expanding it into full support for exceptions handling, finally blocks, or any of the other features implemented in other (scripting) languages. Looking for any feedback. Yair

RE: Bash4: Problem retrieving "$?" when running with "-e"

2013-04-12 Thread Lenga, Yair
GET_BACKUP_DATA Fi Any other suggestion for portable code will be appreciated. Yair. -Original Message- From: Chet Ramey [mailto:chet.ra...@case.edu] Sent: Friday, April 12, 2013 11:16 AM To: Lenga, Yair [ICG-MKTS] Cc: 'bug-bash@gnu.org'; chet.ra...@case.edu Subject: Re:

Bash4: Problem retrieving "$?" when running with "-e"

2013-04-12 Thread Lenga, Yair
the "immediate exit". Can anyone comment on my interpretation. Is there alternative solution that will allow retrieval of the status of single commands when running With the '-e' ? Thanks Yair Lenga

RE: Possible bug with BASH V4: The "$!"

2013-04-12 Thread Lenga, Yair
] ; then kill $!; fi ; sleep 20) & ... ( DO_somthing ; if [ PROBLEM ] ; then kill $!; fi ; sleep 20) & The user is very unlikely to expect the second subshell to kill the first subshell. In any case, I've modified my scripts to use "${BASHPID:-$!}" to get them to w

RE: Possible bug with BASH V4: The "$!"

2013-04-11 Thread Lenga, Yair
& According to POSIX, both calls should print "" (nothing). As the background command does not come from the "current" shell. With BASH4, The first call will print "" (nothing), second call will print the PID of the first call. This is very confusing, and prob

Possible bug with BASH V4: The "$!"

2013-04-11 Thread Lenga, Yair
o the child process. Is it possible to add back the functionality to allow the child process to somehow retrieve it's OWN PID. I assume that the behavior of "$$" cannot be modified at this time. Is there any other workaround ? Thanks Yair Lenga

Error Handling with bash script

2010-05-24 Thread Lenga, Yair
r_return' should address this problem. It will cause 'f1' to return immediately (with non-zero return code), if the 'cp' fail, without executing the following step1/2/3. I believe that adding this option will make it much easier to write reliable scripts that can properly handle many common error conditions. Yair Lenga yair.le...@citi.com

Error Handling with bash script

2010-05-24 Thread Lenga, Yair
r_return' should address this problem. It will cause 'f1' to return immediately (with non-zero return code), if the 'cp' fail, without executing the following step1/2/3. I believe that adding this option will make it much easier to write reliable scripts that can properly handle many common error conditions. Yair Lenga yair.le...@citi.com