与文件不工作猛砸的源命令来自互联网curl'd [英] Bash's source command not working with a file curl'd from internet

查看:99
本文介绍了与文件不工作猛砸的源命令来自互联网curl'd的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用卷曲,这样对源来自互联网脚本文件:来源≤(卷曲URL);回声完成,和我看到的是'做'相呼应的的卷曲甚至开始下载文件!

I am trying to source a script file from the internet using curl, like this: source <( curl url ); echo done , and what I see is that 'done' is echoed before the curl even starts to download the file!

下面是实际的命令和输出:

Here's the actual command and the output:

-bash-3.2# source <( curl --insecure https://raw.github.com/gurjeet/pg_dev_env/master/.bashrc ) ; echo done
done
-bash-3.2# % Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2833 100 2833 0 0 6746 0 --:--:-- --:--:-- --:--:-- 0

我不是太担心'做'被呼应之前或之后任何事情,我特别关注,为什么source命令不会读取和脚本行动!

I am not too worried about 'done' being echoed before or after anything, I am particularly concerned why the source command wouldn't read and act on the script!

此命令对我LinuxMint的bash作为预期,但没有对CentOS的服务器的庆典!

This command works as expected on my LinuxMint's bash, but not on the CentOS server's bash!

推荐答案

起初,我没有注意到你正在使用bash 3.2。该版本将不会从一个进程被代替,但后来的版本,如猛砸4做的。

At first, I failed to notice that you're using Bash 3.2. That version won't source from a process substitution, but later versions such as Bash 4 do.

您可以保存文件,然后执行它的正常来源:

You can save the file and do a normal source of it:

source /tmp/del

(从您的评论使用的文件)

(to use the file from your comment)

或者,您可以使用的/ dev /标准输入和下面的字符串和引用命令替换:

Or, you can use /dev/stdin and a here-string and a quoted command substitution:

source /dev/stdin <<< "$(curl --insecure https://raw.github.com/gurjeet/pg_dev_env/master/.bashrc)"; echo done

这篇关于与文件不工作猛砸的源命令来自互联网curl'd的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆