Skip to content

Commit db669ca

Browse files
committed
Changed the way goscripts are handled.
By default, expects the goscript file to be a valid .go file, ie no #! in the begin of first line. Remove the call to setTime(scriptPath) since the bin will have the same time of the source file.
1 parent f7eba97 commit db669ca

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

cmd/goscript.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ var ENVIRON []string
3232
var fShared = flag.Bool("shared", false,
3333
"whether the script is used on a mixed network of machines or "+
3434
"systems from a shared filesystem")
35+
36+
var hasLineInterpreter = flag.Bool("li", false, "wheter the script has the first line as a #! comment. Defaults to false")
3537

3638
func usage() {
3739
flag.PrintDefaults()
@@ -97,15 +99,19 @@ Flags:
9799

98100
// === Compile and link
99101
scriptMtime := getTime(scriptPath)
100-
comment(scriptPath, true)
102+
if *hasLineInterpreter {
103+
comment(scriptPath, true)
104+
}
101105
compiler, linker, archExt := toolchain()
102106

103107
ENVIRON = os.Environ()
104108
objectPath := path.Join(binaryDir, "_go_."+archExt)
105109

106110
cmdArgs := []string{path.Base(compiler), "-o", objectPath, scriptPath}
107111
exitCode := run(compiler, cmdArgs, "")
108-
comment(scriptPath, false)
112+
if *hasLineInterpreter {
113+
comment(scriptPath, false)
114+
}
109115
if exitCode != 0 {
110116
os.Exit(exitCode)
111117
}
@@ -116,7 +122,7 @@ Flags:
116122
}
117123

118124
// Set mtime of executable just like the source file
119-
setTime(scriptPath, scriptMtime)
125+
//setTime(scriptPath, scriptMtime)
120126
setTime(binaryPath, scriptMtime)
121127

122128
// Cleaning

0 commit comments

Comments
 (0)