指示文件中的编程语言,不带扩展名 [英] Indicate programming language in a file without extension

查看:85
本文介绍了指示文件中的编程语言,不带扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在编写可执行脚本和使用通用语言(例如Python)的声明性配置文件时,我经常发现不希望在文件名中添加扩展名.许多语法突出显示的文本编辑器(例如Geany)随后无法自动确定文件类型.

When writing executable scripts, and declarative configuration files that use a common language (eg. Python), I often find it undesirable to add an extension to the file name. Many syntax-highlighting text editor (eg. Geany) are subsequently unable to automatically determine the filetype.

是否有用于向编辑者指示文件中源类型的标准方法?

Is there any standard method for indicating to editors the type of source in the file?

推荐答案

通常使用shebang行作为备用.

Typically the shebang line is used as a fall-back.

例如,不带扩展名的Ruby脚本将以以下内容开头:

For example, a Ruby script without an extension would begin with:

#!/usr/bin/env ruby

这篇关于指示文件中的编程语言,不带扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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