这是一个 shell 脚本,它根据调用的参数执行一些操作:
if [ $1 = "-add" ]
then
...
elif [ $1 = "-remove" ]
...
else
...
fi
Run Code Online (Sandbox Code Playgroud)
脚本是可执行的(在/usr/bin
目录中创建了指向它的链接)。因此,我可以通过指定 .txt 文件中添加的链接名称从 shell 调用它/usr/bin
。
我想要的是在调用过程中自动检测脚本可能的参数(在我的例子中是-add
, )。-remove
这意味着当我键入与脚本调用相关的命令,然后键入-re
并按选项卡按钮时,它会提示它-remove
并为我自动填充它。
需要如何定义参数才能达到这一目标?
尝试在 shell 配置文件中创建别名或在/usr/bin
目录中为所有可能的输入创建几个链接,并且工作正常,但我认为这不是最佳解决方案。
我需要输出某种类型的数据,延迟JSP.我已经用下一个方式完成了它:
for (int i = 0; i < arr.length; i++) {
out.println(arr[i] + " ");
out.flush();
Thread.sleep(100 * i);
}
Run Code Online (Sandbox Code Playgroud)
并且І已经得到了预期的结果(数据输出有延迟).然后,我尝试使用该方法转发到另一个JSP:
<% out.println("Hello there.");
out.flush(); %>
<jsp:forward page="/another.jsp"></jsp:forward>
Run Code Online (Sandbox Code Playgroud)
它对我没有用(JSP没有被转发).但是,以这种方式转发而不处理out.flush()工作正常.有什么问题,如何在显示当前数据之后转发到另一个JSP?
我面临下一个情况:
char *arr[] = {"hello", (char *) 0};
上面将创建一个char指针数组,并arr[0]
指向"hello"字符串的第一个字符.但是,(char *) 0
在这种情况下是什么以及它可以在哪里使用?
当我尝试调用arr[1]
它时,会给我下一个错误:
segmentation fault (core dumped)
编辑:我在创建posix_spawn函数的argv参数时使用它(它需要在最后一个位置有一个空指针):
The argument argv is an array of character pointers to null-terminated strings. The last member of this array shall be a null pointer and is not counted in argc.