开发者

What is the `< <()` syntax?

开发者 https://www.devze.com 2023-03-06 23:00 出处:网络
I\'ve been using RVM for a while, and every time I just copied and pasted the following comma开发者_如何转开发nd to get it setup:

I've been using RVM for a while, and every time I just copied and pasted the following comma开发者_如何转开发nd to get it setup:

bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

It bugs me that I don't fully understand the syntax, and why we need the double <, and the parentheses. Can some one explain this or point me to the right reference?


The first one is input redirection. It feeds the contents of a file into the program as input. The second construct is <() and it's process redirection: it treats output of a process like a file. In this case, the effect is that you will run the contents of that url as though it was a bash script -- very dangerous! If you don't trust to source completely, don't do that. An attacker could use this method to have you run commands that would compromise your system.


Just my 2 cents. Bashs structure <() as @Daenyth stated "treats output of a process like a file". This structure may be very useful. Just consider following:

 diff <(ls dir1) <(ls dir2)

This will use vimdiff to show differences between contents of dir1 and dir2. Using vimdiff instead diff will even cooler.

0

精彩评论

暂无评论...
验证码 换一张
取 消