Created
July 30, 2021 10:19
-
-
Save taniguti/f39bf0ca24e3cadc48fd8171a1810867 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
taniguchi.takanori@O-13660-MAC:/tmp[3057]% cat a.sh | |
#!/bin/bash | |
function hoge(){ | |
local i | |
i="I am local" | |
g="I am global" | |
} | |
taniguchi.takanori@O-13660-MAC:/tmp[3058]% cat b.sh | |
#!/bin/bash | |
i="who am i?" | |
g=$i | |
echo "i: $i" | |
echo "g: $g" | |
echo "use . a.sh" | |
. a.sh | |
hoge | |
echo "i: $i" | |
echo "g: $g" | |
: ----- | |
i="who am i?" | |
g=$i | |
echo "use source a.sh" | |
source a.sh | |
hoge | |
echo "i: $i" | |
echo "g: $g" | |
taniguchi.takanori@O-13660-MAC:/tmp[3059]% ./b.sh | |
i: who am i? | |
g: who am i? | |
use . a.sh | |
i: who am i? | |
g: I am global | |
use source a.sh | |
i: who am i? | |
g: I am global | |
taniguchi.takanori@O-13660-MAC:/tmp[3060]% sw_vers | |
ProductName: macOS | |
ProductVersion: 11.5 | |
BuildVersion: 20G71 | |
taniguchi.takanori@O-13660-MAC:/tmp[3061]% bash --version | |
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20) | |
Copyright (C) 2007 Free Software Foundation, Inc. | |
taniguchi.takanori@O-13660-MAC:/tmp[3062]% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment