为什么斯卡拉使用逆转井号(#!),而不是只设置间preTER到斯卡拉 [英] Why does Scala use a reversed shebang (!#) instead of just setting interpreter to scala

查看:173
本文介绍了为什么斯卡拉使用逆转井号(#!),而不是只设置间preTER到斯卡拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Scala的文件显示,创建Scala的脚本的方式是这样的:

The scala documentation shows that the way to create a scala script is like this:

#!/bin/sh
exec scala "$0" "$@"
!#
/* Script here */

我知道,这个执行阶的脚本文件的名称和传递给它的参数,以及Scala的命令显然知道读取启动这样的文件,而忽略了一切的反向家当#!

我的问题是:是否有任何理由,我应该使用这个(相当冗长)格式的斯卡拉脚本,而不只是:

My question is: is there any reason why I should use this (rather verbose) format for a scala script, rather than just:

#!/bin/env scala
/* Script here */

这,就一个我可以从一个快速测试出来,不完全是一回事,但更简洁。

This, as far a I can tell from a quick test, does exactly the same thing, but is less verbose.

推荐答案

多大的文件?通常情况下,这样的事情(通常被称为'的EXEC黑客')的前推荐/斌/ env的很常见,这是获得功能的最佳途径。需要注意的是的/ usr / bin中/ env的 /斌/ env的更常见,而且应该用来代替。

How old is the documentation? Usually, this sort of thing (often referred to as 'the exec hack') was recommended before /bin/env was common, and this was the best way to get the functionality. Note that /usr/bin/env is more common than /bin/env, and ought to be used instead.

这篇关于为什么斯卡拉使用逆转井号(#!),而不是只设置间preTER到斯卡拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆