多行命令.go在SciTE中

huangapple go评论96阅读模式
英文:

Multiline command.go in SciTE

问题

简短描述

这涉及到SciTE和go语言在Windows中的使用(特别是Windows 7)。这是我第一次使用SciTE,所以如果有其他方法可以实现我的目标,也可以。

目标:通过按下一个键,编译、链接和执行新创建的二进制文件。

详细描述

我想在SciTE中设置编译/链接/执行"go"命令。这可能会有点混淆,因为它也适用于go语言。以下是我目前的设置:

command.compile.*.go=8g $(FileNameExt)
command.build.*.go=8l -o $(FileName).exe $(FileName).8
command.go.*.go=$(FileName).exe

我希望有这样的设置:

command.go.*.go=\
8g $(FileNamExt)\
8l -o $(FileName).exe $(FileName).8\
$(FileName).exe

如果这样工作,它将编译文件,链接它,然后运行可执行文件。但实际上发生的是:

8g hello.go8l -o hello.exe hello.8hello.exe

而应该是:

8g hello.go
8l -o hello.exe hello.8
hello.exe

每行都会被执行。

英文:

The Short

This deals with SciTE and the go language in Windows (in particular, Windows 7). This is my first time using SciTE, so if there is another way to achieve my goal that is fine as well.

Goal: With one key press, compile, link, and execute the newly created binary.

The Long

I want to setup the compile/link/excecute under the "go" command in SciTE. This may be slightly confusing as it is also for the go language. Here is what I have so far:

command.compile.*.go=8g $(FileNameExt)
command.build.*.go=8l -o $(FileName).exe $(FileName).8
command.go.*.go=$(FileName).exe

What I would like is to have something like:

command.go.*.go=\
8g $(FileNamExt)\
8l -o $(FileName).exe $(FileName).8\
$(FileName).exe

If this worked the way I intended it would compile the file, link it, and then run the executable. What happens is:

8g hello.go8l -o hello.exe hello.8hello.exe

When it should be:

8g hello.go
8l -o hello.exe hello.8
hello.exe

Where each line is executed.

答案1

得分: 2

写一个批处理脚本如下:

@echo off
if (%1 == "") (goto end)

set gofile=%1%
shift

8g %gofile%.go
8l -o %gofile%.exe %gofile%.8
%gofile%.exe

:end

批处理文件可以放在任何地方,但假设它在'C:\one\two\three\GO.bat'(不包括引号)。在SciTE属性文件中更改:

command.go.*.go=$(FileName).exe

command.go.*.go=C:\one\two\three\GO.bat $(FileName)

当你按下F5或点击“Go”时,它将编译、链接并执行文件。

英文:

Write a batch script like so:

@echo off
if (%1 == "") (goto end)

set gofile=%1%
shift

8g %gofile%.go
8l -o %gofile%.exe %gofile%.8
%gofile%.exe

:end

The batch file can be anywhere, but let's say it's in 'C:\one\two\three\GO.bat' sans the quotes. In the SciTE property file change:

command.go.*.go=$(FileName).exe

to

command.go.*.go=C:\one\two\three\GO.bat $(FileName)

And when you hit F5 or click on "Go", it will compile, link, and execute the file.

答案2

得分: 0

你在使用行继续转义符时没有加空格,这就是为什么看起来是这样的。

我不了解Windows,但在Unix shell中,你可以使用分号(或者像peterSO提到的&&,在这里更合适)来分隔多个命令。

你仍然可以换行,但要意识到由于换行不被视为语法上的重要标志,所以要适当地添加分隔符。

英文:

You have line continuation escapes with no spaces which is why it looks like that.

I don't know Windows, but in unix shells you can separate multiple commands with semicolons (or && as peterSO mentions, which is more appropriate here).

You can still wrap, but realize that it's not going to consider the wrapping syntactically significant due, so add separation characters as appropriate.

huangapple
  • 本文由 发表于 2010年12月22日 05:15:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/4503972.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定