在带有鱼2.3.1的Ubuntu Server 16.10 x64上,我的<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form id="form1" name="form1" enctype="multipart/form-data">
<div>
First Name
<input type="text" name="FirstName" id="FirstName">
<br>Live Update
<input type="text" name="LiveUpdate" id="LiveUpdate">
<br>Image
<input type="file" id="images" name="images" accept="image/*">
</div>
<input type="submit">
</form>
<script>
var form = document.getElementById("form1");
form.onsubmit = function(e) {
e.preventDefault();
function ajax_post(form) {
// Create our XMLHttpRequest object
var hr = new XMLHttpRequest();
// Create some variables we need to send to our PHP file
var url = "/dev/null";
hr.open("POST", url, true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "multipart/form-data");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if (hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
//document.getElementById("success_insert").innerHTML = return_data;
}
}
// Send the data to PHP now... and wait for response to update the status div
hr.send(new FormData(form)); // Actually execute the request
// document.getElementById("success_insert").innerHTML = "processing...";
}
ajax_post(this)
}
</script>
</body>
</html>
exe在stdout上生成此函数
uru_rt
通过function uru
set -x URU_INVOKER fish
# uru_rt must already be on PATH
uru_rt $argv
if test -d "$URU_HOME" -a -f "$URU_HOME/uru_lackee.fish"
source "$URU_HOME/uru_lackee.fish"
else if test -f "$HOME/.uru/uru_lackee.fish"
source "$HOME/.uru/uru_lackee.fish"
end
end
运行时。 uru_rt admin install
函数提供基于golang的跨平台ruby版本管理器工具https://bitbucket.org/jonforums/uru
在bash系统上,我通过将uru
放在启动文件中来注入uru
函数,以便shell中存在eval "$(uru_rt admin install)"
。
在鱼上,运行uru
会因此失败而奖励我
eval (uru_rt admin install)
我也尝试过$ eval (uru_rt admin install)
Missing end to balance this begin
- (line 1): begin; function uru set -x URU_INVOKER fish # uru_rt must already be on PATH uru_rt $argv if test -d "$URU_HOME" -a -f "$URU_HOME/uru_lackee.fish" source "$URU_HOME/uru_lackee.fish" else if test -f "$HOME/.uru/uru_lackee.fish" source "$HOME/.uru/uru_lackee.fish" end end
^
from sourcing file -
called on line 60 of file /usr/share/fish/functions/eval.fish
in function “eval”
called on standard input
source: Error while reading file “-”
同样的结果。
正如预期的那样,当set u1 (uru_rt admin install); eval "$u1"
uru_rt admin install > ~/.config/fish/functions/uru.fish
函数变为持久可用时。虽然这是一个选项,但我的偏好是在uru
eval
作为钓鱼的菜鸟,我如何使用{b}的~/.config/fish/config.fish
类似uru
将eval
函数动态注入环境?
答案 0 :(得分:3)
Fish的eval
是一个围绕其source
内置函数的包装函数,当你传递多行时,它的参数分裂似乎有些奇怪(甚至可能是一个bug)。
然而,在这种情况下,如果您只使用source
,它会更简单,更快速且实际有效,例如uru_rt admin install | source
。
假设uru_rt admin install
确实需要被调用 - 如果它只是将该代码打印到stdout而不更改它,你也可以简单地保存该函数,例如:在〜/ .config / fish / functions / uru.fish。