|
From: | Geoff Hull |
Subject: | Re: "Variation" in Command Substitution Behaviour |
Date: | Wed, 1 Mar 2017 19:04:06 +1300 |
Hi,
> Am 28.02.2017 um 11:00 schrieb Andreas Schwab <schwab@linux-m68k.org>:
>
> On Feb 28 2017, Geoff Hull <gbhull@gmail.com> wrote:
>
>> If I "source" the attached file (i.e. ". test_aliases") in a bash session,
>> then run the following:
>>
>> assemble_fam1
>> assemble_fam2
>> say_families
>>
>> I see the following output:
>>
>> Flintstones=wilma:bam-bam:fred
>> Rubbles=barney
In which version of Bash are you observing this? For me it's working using this order, but when I swap assemble_fam1 and assemble_fam2 I observe a strange behavior, that RUBBLES gets reset and I get your output:
$ assemble_fam1
$ assemble_fam2
$ say_families
Flintstones=wilma:bam-bam:fred
Rubbles=betty:pebbles:barney
$ reset_vars
$ assemble_fam2
$ say_families
Flintstones=
Rubbles=betty:pebbles:barney
$ assemble_fam1
$ say_families
Flintstones=wilma:bam-bam:fred
Rubbles=barney
This I have in 4.2 and 4.4.
$ reset_vars
+ reset_vars
+ unset FSTONES RUBBLES
$ assemble_fam2
+ barney
++ echo barney
+ RUBBLES=barney
$ say_families
+ RUBBLES=betty:pebbles:barney
+ say_families
+ echo Flintstones=
Flintstones=
+ echo Rubbles=betty:pebbles:barney
Rubbles=betty:pebbles:barney
$ assemble_fam1
+ fred
++ echo fred
+ FSTONES=fred
+ FSTONES=wilma:bam-bam:fred
$ say_families
+ say_families
+ echo Flintstones=wilma:bam-bam:fred
Flintstones=wilma:bam-bam:fred
+ echo Rubbles=barney
Rubbles=barney
> It seems like the shell is eating an extra newline. Try typing an empty
> line after assemble_fam2:
The extra newline doesn't help for the observation above. While defining assemble_famX in one line for both does as mentioned by Geoff.
-- Reuti
[Prev in Thread] | Current Thread | [Next in Thread] |