Bash : Dot-Command Double Trouble

86 Views Asked by At

if i use the dot-command from bash (or "source" ) it executes TWICE ===== demo === ( for import ) ====== (saved as "demo")

x+="|"
subResTest() {
    return 0 # do nothing 
}   
echo "HI"$x

====== test ==== ( same directory as demo )

#/bin/bash
. demo
for ((i=1 ; i<10 ; i++)) ; do
    echo -n $i$x 
    subResTest
done
echo

====== Result =====

./test
HI|
HI||
1||2||3||4||5||6||7||8||9||

================ So what is going on ? The problem is, if something should only executes once per import it leads to wrong results - even in this simple example.

Running System : Mx Linux 19.2 (debian-based) bash 5.0.3(1) test starts from an xfce4-terminal

0

There are 0 best solutions below