我想从一个bash shell脚本运行一个命令,该脚本在单引号和变量中有单引号和一些其他命令.
例如 repo forall -c '....$variable'
在此格式中,$
进行转义并且不扩展变量.
我尝试了以下变化,但他们被拒绝了:
repo forall -c '...."$variable" '
repo forall -c " '....$variable' "
" repo forall -c '....$variable' "
repo forall -c "'" ....$variable "'"
Run Code Online (Sandbox Code Playgroud)
如果我用值代替变量来执行命令就好了.
请告诉我哪里出错了.
我知道这个问题已被多次询问,我检查了所有的解决方案并研究了一切.但是,这根本不适合我.
我不知道我做错了什么.有人可以帮帮我吗?
我正在加载一个本地html文件WebView
,然后调用JavaScript函数:
wv.loadUrl("file:///android_asset/sample.html");
wv.getSettings().setJavaScriptEnabled(true);
JavascriptInterface javasriptInterface = new JavascriptInterface(MyActivity.this);
wv.addJavascriptInterface(javasriptInterface, "MyInterface");
wv.loadUrl("javascript:loadpath()");
Run Code Online (Sandbox Code Playgroud)
HTML文件是:
<html>
<head>
</head>
<body>
<script type="text/javascript">
function callDoSomething() {
// Do something
}
function loadpath() {
// Is not called no matter whatever operation I do here. Just printing a string, setting variable, android callback anything.
document.write("Hi");
document.getElementById('img').src = "path.png";
}
</script>
<form name="myForm" action="FORM">
<img src="" alt="Autofill" /><br>
<input type="button" value="Submit" onClick="callDoSomething()" />
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)