我最近刚开始对scala进行编程,在“scala中的编程”(www.artima.com/pins1ed)一书中,介绍了在linux中执行scala脚本的以下方法:
#!/bin/sh
exec scala "$0" "$@"
!#
// Say hello to the first argument
println("Hello, "+ args(0) +"!")
现在我已经使用linux很长时间了,但是bash脚本不是我的专长。现在我可以猜到这种scrpt是如何工作的(而且它运行得很好),但是我想知道!#和$@到底做了什么。
我需要从程序中确定Linux命令是否是内置的。我还需要偶尔运行内置命令。我将使用别名作为示例,它也适用于其他内置程序。
我找到的一个恰当的答案是:
sh -c 'type alias'
这将返回‘别名是shell内置的’,这正是我所需要的。但是.我也得负责。而我尝试过的任何事情都不会这样做。所有这些都在终端窗口中失败(并以编程方式):
sh -c 'alias' (无任何输出)
sh -c 'command alias' (无任何输出)
sh -c 'builtin alias' (sh: 1:内置:未找到)
sh
我一直在遵循Chris Simmonds的“掌握嵌入式linux编程”一书中的命令。我已经创建了工具链、内核zImage和busybox文件系统。当我将它们组合在一起在QEMU上运行时,它应该会显示一个root shell提示。 当我运行该命令时,我得到以下结果。 /bin/sh: can't access tty; job control turned off
input: ImExPS/2 Generic Explorer Mouse as /devices/platform/amba/amba:fpga/10007000.kmi/serio1/input/input2 当我