1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

XonshAdvent Calendar 2017

Day 12

source+pipe

Last updated at Posted at 2017-12-11

xonshのアドベントカレンダー記事だし、
xonshと他の対象としてとりあえずbashとzshと比較してソースコード。
test.shはすべて同じもの。

普通にsource

Bash, Zsh

test.sh
a=2
echo "test"
test2.sh
a=1
source test.sh
echo $a
bash test2.sh
# -> test
# -> 2
zsh test2.sh
# -> test
# -> 2

xonsh

test.sh
a=2
echo "test"
test2.sh
a=1
source test.sh
echo @(a)
xonsh test2.sh
# -> test
# -> 2

つなぐ

bash, zsh

test.sh
a=2
echo "test"
test2.sh
a=1
source test.sh | sed -e "s/test/hoge/"
echo $a
bash test2.sh
# -> hoge
# -> 1
zsh test2.sh
# -> hoge
# -> 1

xonsh

test.sh
a=2
echo "test"
test2.sh
a=1
source test.sh | sed -e "s/test/hoge/"
echo @(a)
xonsh test2.sh
# -> hoge
# -> 2

なるほど。

楽しい

pow.py
print(i*i)
logger.sh
for i in range(1,10):
    source pow.py > @("%02d.log"%i)
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?