[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

multi-line alias executed out of order

From: Andrew Martin
Subject: multi-line alias executed out of order
Date: Mon, 16 Dec 2013 21:33:41 -0700

Configuration Information [Automatically generated, do not change]:Machine: 
x86_64OS: linux-gnuCompiler: gccCompilation 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 
-Walluname 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/LinuxMachine Type: 
Bash Version: 4.2Patch Level: 45Release 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.
address@hidden:~$ cat script.sh#!/bin/bash(echo -n "$1 "; date 
+%S.%N)address@hidden:~$ alias foo1alias foo1='~/script.sh one; source 
~/script.sh two; source ~/script.sh three; ~/script.sh four'address@hidden:~$ 
alias foo2alias foo2='~/script.sh one;source ~/script.sh two;source ~/script.sh 
three;~/script.sh four;'address@hidden:~$ foo1one 09.742581873two 
09.745315889three 09.749212492four address@hidden:~$ foo2one 11.805819275four 
11.819741270three 11.828260887two 11.829470548
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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]