Re: smart indented HERE docs

2016-08-21 Thread Pierre Gaston
On Mon, Aug 22, 2016 at 6:47 AM, Derek Schrock wrote: > > Would it be possible to add a new character (+) to the here-doc such > that the number of tabs remove are the number after the closing > delimiter (EOF in the above example): > > > cat <<+ EOF > Testing

smart indented HERE docs

2016-08-21 Thread Derek Schrock
I believe this would be a feature request however if this already exists directly in bash please let me know. With <<- you can indent a here-doc such that all tabs will be removed. This can be nice for style reasons in your script however to give the impression of formatting in the here-doc spaces

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread L. A. Walsh
Chet Ramey wrote: Posix made an error in the 1992 version, in that the specification of set -e was subtly incompatible with historical... The relevant change was probably the change in the set of commands to which `set -e' applies. The (( command (among others) was added to that list in bash-4

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Dmitry Goncharov
On Sun, Aug 21, 2016 at 03:04:07PM -0400, Chet Ramey wrote: > The current text in redirection says: > > Bash handles several filenames specially when they are used in redirec- >tions, as described in the following table. If the operating system on >which bash is running provides t

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Dmitry Goncharov
On Sun, Aug 21, 2016 at 04:03:05PM -0400, Grisha Levit wrote: > On Aug 20, 2016 9:32 PM, "Dmitry Goncharov" wrote: > > With this new contract how can the user write portable bash code which > tests if a fd refers to a pipe? > > The test command seems to have the behavior you expect. > > $ uname

Patch to fix braces test

2016-08-21 Thread Dmitry Goncharov
Good morning. The patch in the attachment fixes the test in braces.c. Repace free_array with strvec_dispose. Remove unused fatal_error and report_error to eliminate linking failures. regards, Dmitry diff --git a/braces.c b/braces.c index c6d567f..4e66fb3 100644 --- a/braces.c +++ b/braces.c @@ -

Patch to fix a leak in expand_amble.

2016-08-21 Thread Dmitry Goncharov
Good morning. The patch in the attachment fixes a leak in expand_amble. regards, Dmitry diff --git a/braces.c b/braces.c index 61c1ab1..c6d567f 100644 --- a/braces.c +++ b/braces.c @@ -319,6 +319,8 @@ expand_amble (text, tlen, flags) if (tresult == 0) { interna

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread Chet Ramey
On 8/21/16 8:30 PM, L. A. Walsh wrote: > >Keeping "-e" semantics in a "bo[e]rn[e]-again-shell" > compatible with the original shell would be the smart way to > go. POSIX changed it to be incompatible with historical > implementations -- thus, creating a new standard (@Chet), that > was no long

is there a way to see if a var is declared so we can safely assign to it (and...)

2016-08-21 Thread L. A. Walsh
This is a sample, of what I want: #!/bin/bash -u assign_var () { #if declared var; then var=assigned #else printf warn about global definition...; fi } lvl1 () { declare var assign_var printf "lvl1 var=%s\n" "$var" } lvl1 printf "main var after lvl1=%s\n" "${var:-undef}"

Re: Intriguing error with arithmetic evaluation

2016-08-21 Thread L. A. Walsh
Greg Wooledge wrote: On Mon, Aug 15, 2016 at 03:15:13AM -0700, L. A. Walsh wrote: Calculations shouldn't ever trigger "-e" except for things like division by 0 (which doesn't trigger it, as the calculation dies before an return value can be calculated); it's counter-intuitive. You ma

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Grisha Levit
On Aug 20, 2016 9:32 PM, "Dmitry Goncharov" wrote: > With this new contract how can the user write portable bash code which tests if a fd refers to a pipe? The test command seems to have the behavior you expect. $ uname SunOS $ mkfifo /tmp/pipe $ cat < /tmp/pipe & [1] 25376 $ exec 6>/tmp/pipe $

Re: a patch to fix sh_stat on SunOS

2016-08-21 Thread Chet Ramey
On 8/20/16 9:31 PM, Dmitry Goncharov wrote: > On Thu, Aug 11, 2016 at 07:52:51AM -0400, Chet Ramey wrote: >> On 8/10/16 5:38 PM, Dmitry Goncharov wrote: >> > does "If any file argument to one of the primaries is of the form >>> > /dev/fd/n, then file descriptor n is checked.". >>> >>>

Re: fix a memory leak in netopen

2016-08-21 Thread Chet Ramey
On 8/20/16 10:37 PM, Dmitry Goncharov wrote: > Good morning. > > The patch in the attachment fixes a memory leak in netopen. Thanks for the report and fix. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey,