这似乎是一件简单的事情,但我无法找到任何关于此的信息。
我如何使用以下内容:
// html: <input type="text" onchange="validate()">
function validate(e) {
e.preventDefault();
if(isValid(this.value)) {
// make valid somehow
} else {
// make invalid somehow
}
}
Run Code Online (Sandbox Code Playgroud)
以便以下 CSS 可以正常工作:
input:valid {
background: green;
}
input:invalid {
background: red;
}
Run Code Online (Sandbox Code Playgroud) 我在我的路径中将以下脚本保存为"lspkg":
#!/bin/bash
args=("$@")
for item in ${args[@]}; do
echo "$item"
done
Run Code Online (Sandbox Code Playgroud)
当我运行时lspkg /absolute/path/to/file,它按预期工作,打印路径.但是,以下行为给我带来了很多麻烦:
转义路径中的空格并没有真正逃离空间:
$ lspkg /absolute/path/to/file\ with\ spaces
/absolute/path/to/file\
with\
spaces
Run Code Online (Sandbox Code Playgroud)
将路径放在引号中不会使bash将其视为单个字符串:
$ lspkg "/absolute/path/to/file with spaces"
"/absolute/path/to/file
with
spaces"
Run Code Online (Sandbox Code Playgroud)
为什么会这样,这个问题怎么解决?