Re: consistency probs var & function re-use

2017-06-13 Thread Greg Wooledge
On Sun, Jun 11, 2017 at 03:51:26PM -0700, L A Walsh wrote: > I was pointing out that the reason 'declare' used a newline, was that he > had not quoted the input to 'x', which is expanded to a newline > before it is assigned to 'x'. You are completely wrong here. My variable 'x' had a newline in i

Re: consistency probs var & function re-use

2017-06-11 Thread L A Walsh
Charles Daffern wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. That shows that "-p" doesn't insert newlines: > x="$'foo\nbar'" > declare -p x declare -- x="\$'foo\\nbar'" You do not have any newlines in that string, so o

Re: consistency probs var & function re-use

2017-06-11 Thread L A Walsh
Chet Ramey wrote: You are misunderstanding what that is supposed to do, or ignoring it. `declare -p' quotes its output in a way that allows it to be reused as shell input. Executing the output of `declare -p' will recreate the variable with an identical value. Re-use as shell input? That'

Re: consistency probs var & function re-use

2017-06-11 Thread Chet Ramey
On 6/11/17 5:57 PM, L A Walsh wrote: > > > Chris F.A. Johnson wrote: >> On Fri, 9 Jun 2017, L A Walsh wrote: >>> >>> First problem: If you are assigning a string to a variable, >>> you need to put quotes around the string. >> >>You don't need to quote it unless it contains literal whit

Re: consistency probs var & function re-use

2017-06-11 Thread L A Walsh
Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. --- Not true if you want to reproduce the strin

Re: consistency probs var & function re-use

2017-06-11 Thread L A Walsh
Chris F.A. Johnson wrote: A newline IS literal whitespace. I'm glad you think so. I tend to agree, but I was clarifying for those that might have a different definition.

Re: consistency probs var & function re-use

2017-06-10 Thread Charles Daffern
>First problem: If you are assigning a string to a variable, > you need to put quotes around the string. That shows that "-p" > doesn't insert newlines: > > > x="$'foo\nbar'" > > declare -p x > declare -- x="\$'foo\\nbar'" You do not have any newlines in that string, so of course the demo

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. Not exactly t

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. Not exactly t

Re: consistency probs var & function re-use

2017-06-09 Thread L A Walsh
Chris F.A. Johnson wrote: On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. Not exactly true -- "any" type of white space, inc

Re: consistency probs var & function re-use

2017-06-09 Thread Chris F.A. Johnson
On Fri, 9 Jun 2017, L A Walsh wrote: First problem: If you are assigning a string to a variable, you need to put quotes around the string. You don't need to quote it unless it contains literal whitespace. -- Chris F.A. Johnson,

Re: consistency probs var & function re-use

2017-06-09 Thread L A Walsh
Greg Wooledge wrote: What are you talking about? Consistency between what two things? Are you allergic to newlines? declare -p uses raw newlines in its output whenever it feels they are appropriate. Even in ordinary shell variables: imadev:~$ x=$'foo\nbar' imadev:~$ declare -p x declare -- x="fo