I was able to reproduce this, although there is another fix: remove "source" from the multiline (foo2) alias. I did not look at the alias built-in code lately, but it seems that "source" scripts are put to the stack for later execution and then taken into account in a first-in-last-out order.
cheers, pg On Wed, Dec 18, 2013 at 4:49 AM, Andrew Martin <andrew.mar...@gmail.com> wrote: > Chet & Pierre: > > My apologies, the newlines were somehow removed by my email client. > First, here's a properly formatted pastebin link: > > http://pastebin.com/raw.php?i=AhF89GfT > > And here's another attempt at a properly formatted report: > > Configuration Information [Automatically generated, do not change]: > Machine: x86_64 > OS: linux-gnu > Compiler: gcc > Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' > -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' > -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' > -DSHELL -DHAVE_CONFIG_H -I. -I../bash -I../bash/include > -I../bash/lib -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector > --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall > uname output: Linux ubuntu 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 > 16:20:46 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux > Machine Type: x86_64-pc-linux-gnu > > Bash Version: 4.2 > Patch Level: 45 > Release Status: release > > Description: > In a multi-line alias, where entries are separated by semi-colon, > "source" commands are not executed in-step with all the other > commands. After all the non "source" commands are executed, the > "source" commands are executed in reverse order. See below for an > example. > > Repeat-By: > > ubuntu@ubuntu:~$ cat script.sh > #!/bin/bash > (echo -n "$1 "; date +%S.%N) > ubuntu@ubuntu:~$ alias foo1 > alias foo1='~/script.sh one; source ~/script.sh two; source > ~/script.sh three; ~/script.sh four' > ubuntu@ubuntu:~$ alias foo2 > alias foo2='~/script.sh one; > source ~/script.sh two; > source ~/script.sh three; > ~/script.sh four; > ' > ubuntu@ubuntu:~$ foo1 > one 09.742581873 > two 09.745315889 > three 09.749212492 > four 09.761410711 > ubuntu@ubuntu:~$ foo2 > one 11.805819275 > four 11.819741270 > three 11.828260887 > two 11.829470548 > > Fix: > > Use a single-line alias. Or use the "&&" operator to chain commands > (which changes the functionality to be short-circuit evaluations). > > Also verified this behavior on RHEL6 with bash 4.1.2(1). > > Thanks, > Andrew Martin > > > On Tue, Dec 17, 2013 at 8:41 PM, Andrew Martin <andrewcmar...@msn.com> wrote: >> >> >>> Date: Tue, 17 Dec 2013 10:14:23 -0500 >>> From: chet.ra...@case.edu >>> To: andrewcmar...@msn.com >>> CC: bug-bash@gnu.org; b...@packages.debian.org; chet.ra...@case.edu >>> Subject: Re: multi-line alias executed out of order >> >>> >>> >>> > Description:In a multi-line alias, where entries are separated by >>> > semi-colon, "source" commands are not executed in-step with all the other >>> > commands. After all the non "source" commands are executed, the "source" >>> > commands are executed in reverse order. See below for an example. >>> > Repeat-By: >>> > ubuntu@ubuntu:~$ cat script.sh#!/bin/bash(echo -n "$1 "; date >>> > +%S.%N)ubuntu@ubuntu:~$ alias foo1alias foo1='~/script.sh one; source >>> > ~/script.sh two; source ~/script.sh three; ~/script.sh >>> > four'ubuntu@ubuntu:~$ >>> > alias foo2alias foo2='~/script.sh one;source ~/script.sh two;source >>> > ~/script.sh three;~/script.sh four;'ubuntu@ubuntu:~$ foo1one >>> > 09.742581873two >>> > 09.745315889three 09.749212492four 09.761410711ubuntu@ubuntu:~$ foo2one >>> > 11.805819275four 11.819741270three 11.828260887two 11.829470548 >> >>> > Fix: >>> > Use a single-line alias. Or use the "&&" operator to chain commands >>> > (which changes the functionality to be short-circuit evaluations). >>> >>> I can't reproduce this on Mac OS X or RHEL 5. You might also consider >>> adding a few newlines into your report for readability. >>> >>> Chet >>> -- >>> ``The lyf so short, the craft so long to lerne.'' - Chaucer >>> ``Ars longa, vita brevis'' - Hippocrates >>> Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/ >