Re: [PATCH 2/2 V2] * doc/make.texi: Document the let function

2020-10-10 Thread Pete Dietl
This whole section is called “Functions for Transforming Text,” but is this
really an accurate title anymore? Maybe we should just rename it to
“Functions.”

Also, I ran ‘’make html”, but it doesn’t look like it does on he website.
Does anyone know how I can build the docs to look like the website locally?


[PATCH 2/2 V2] * doc/make.texi: Document the let function

2020-10-10 Thread Jouke Witteveen
---
Thanks to Martin Dorey for spotting a typo in the first version of this
patch.  I fixed a few others typos too in this revision.  This revision is
sent just so that the previous version does not get applied accidentally.
There may still be parts that could be improved.

The first patch in this series of two remains unchanged.

Regards,
- Jouke

 doc/make.texi | 88 ---
 1 file changed, 76 insertions(+), 12 deletions(-)

diff --git a/doc/make.texi b/doc/make.texi
index 21573c0..4289f84 100644
--- a/doc/make.texi
+++ b/doc/make.texi
@@ -276,6 +276,7 @@ Functions for Transforming Text
 * Text Functions::  General-purpose text manipulation functions.
 * File Name Functions:: Functions for manipulating file names.
 * Conditional Functions::   Functions that implement conditions.
+* Let Function::Lexically scoped variables.
 * Foreach Function::Repeat some text with controlled variation.
 * File Function::   Write text to a file.
 * Call Function::   Expand a user-defined function.
@@ -7032,6 +7033,7 @@ be substituted.
 * Text Functions::  General-purpose text manipulation functions.
 * File Name Functions:: Functions for manipulating file names.
 * Conditional Functions::   Functions that implement conditions.
+* Let Function::Lexically scoped variables.
 * Foreach Function::Repeat some text with controlled variation.
 * File Function::   Write text to a file.
 * Call Function::   Expand a user-defined function.
@@ -7632,7 +7634,7 @@ the file names to refer to an existing file or directory. 
 Use the
 @code{wildcard} function to test for existence.
 @end table
 
-@node Conditional Functions, Foreach Function, File Name Functions, Functions
+@node Conditional Functions, Let Function, File Name Functions, Functions
 @section Functions for Conditionals
 @findex if
 @cindex conditional expansion
@@ -7685,14 +7687,70 @@ the result of the expansion is the expansion of the 
last argument.
 
 @end table
 
-@node Foreach Function, File Function, Conditional Functions, Functions
+@node Let Function, Foreach Function, Conditional Functions, Functions
+@section The @code{let} Function
+@findex let
+@cindex variables, lexically scoped
+
+The @code{let} function provides a means to limit the scope of a variable.
+The substitution of a value bound to a name in a @code{let} expression
+happens only in the text within the lexical scope defined by the @code{let}
+expression.
+
+Additionally, the @code{let} function enables list unpacking.  In that
+regard, it resembles the @code{read} command in the shell, @code{sh}.
+
+The syntax of the @code{let} function is:
+
+@example
+$(let @var{var} [@var{var} ...],@var{list},@var{text})
+@end example
+
+@noindent
+The first two arguments, the @var{var} list and @var{list}, are expanded
+before anything else is done; note that the last argument, @var{text}, is
+@strong{not} expanded at the same time.  Then, each word of the expanded
+value of @var{list} is bound to each of the variable names, @var{var}, in
+turn, with the final variable name being bound to the remainder of the
+expanded @var{list}.  In other words, the first word of @var{list} is
+bound to the first variable @var{var}, the second word to the second
+variable @var{var}, and so on.  If there are fewer words than there are
+@var{var} operands, the remaining @var{var}s are set to empty strings.  If
+there are fewer @var{var}s than words, the last @var{var} is set to what
+is left of the expanded @var{list} after the words bound to the earlier
+@var{var}s are removed.  After all variables are thus bound, @var{text} is
+expanded.
+
+This macro reverses the order of the words in the list that it is given as
+its first argument:
+
+@example
+reverse = $(let first rest,$1,$(if $(rest),$(call reverse,$(rest)) )$(first))
+@end example
+
+@noindent
+The @var{first} and @var{rest} variables are no longer available after the
+macro is expanded.  If variables by those names existed beforehand, they
+are not affected by the expansion of the @code{reverse} macro.
+
+The @code{let} function has no permanent effect on the variables
+@var{var}; their value and flavor after the @code{let} function call are
+the same as they were beforehand.  The values which are taken from
+@var{list} are in effect only temporarily, during the execution of
+@code{let}.  The variables @var{var} are simply-expanded variables
+during the execution of @code{let}.  If @var{var} was undefined
+before the @code{let} function call, it is undefined after the call.
+@xref{Flavors, ,The Two Flavors of Variables}.@refill
+
+@node Foreach Function, File Function, Let Function, Functions
 @section The @code{foreach} Function
 @findex foreach
 @cindex words, iterating over
 
-The @code{foreach} function is very different from other functions.  It
-causes one piece of text 

Re: embedded newlines in shell function variable expansion

2020-10-10 Thread Dmitry Goncharov via Bug reports and discussion for GNU make
On Fri, Oct 9, 2020 at 11:11 AM Byrnes, Robert  wrote:
>
> If I use this Makefile ...
>
> 
> bash$ cat Makefile
> FOO := $(shell echo $(ENTRIES) ; )
> BAR := $(shell echo $(ENTRIES)   )
>
> all:
> @echo FOO = $(FOO)
> @echo BAR = $(BAR)
>
> .PHONY: all
> 
>
> ... and set ENTRIES with embedded newlines, then this happens:
>
> 
> bash$ make 'ENTRIES=
> blartz
> blurfl
> '
> FOO = blartzblurfl
> BAR = blartz blurfl
> 


Good morning.

i opened
https://savannah.gnu.org/bugs/index.php?59247
and attached a patch.
Thanks for your report and the example.

regards, Dmitry



[bug #59247] function shell eats a newline

2020-10-10 Thread Dmitry Goncharov
Follow-up Comment #1, bug #59247 (project make):

The patch in the attachment fixes the issue.

___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59247] function shell eats a newline

2020-10-10 Thread Dmitry Goncharov
Additional Item Attachment, bug #59247 (project make):

File name: sv_59247_func_shell_eats_newline.diff Size:1 KB
   




___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/




[bug #59247] function shell eats a newline

2020-10-10 Thread Dmitry Goncharov
URL:
  

 Summary: function shell eats a newline
 Project: make
Submitted by: dgoncharov
Submitted on: Sat 10 Oct 2020 06:24:33 PM UTC
Severity: 3 - Normal
  Item Group: None
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: None
Operating System: None
   Fixed Release: None
   Triage Status: None

___

Details:

A user reported a bug here

https://lists.gnu.org/archive/html/bug-make/2020-10/msg00016.html.

From:   Byrnes, Robert
Subject:embedded newlines in shell function variable expansion
Date:   Fri, 9 Oct 2020 15:03:24 +

If I use this Makefile ...


bash$ cat Makefile
FOO := $(shell echo $(ENTRIES) ; )
BAR := $(shell echo $(ENTRIES)   )

all:
@echo FOO = $(FOO)
@echo BAR = $(BAR)

.PHONY: all


... and set ENTRIES with embedded newlines, then this happens:


bash$ make 'ENTRIES=
blartz
blurfl
'
FOO = blartzblurfl
BAR = blartz blurfl





___

Reply to this item at:

  

___
  Message sent via Savannah
  https://savannah.gnu.org/