-
Notifications
You must be signed in to change notification settings - Fork 0
fix: windows command execution #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
b04a573
f706f56
eae0f74
59fff59
5f2ab5c
d64aa54
4e6f975
0538e1a
db646e8
a41199b
3ecd9fa
6c9001f
8ac5c00
b3996ba
8a227fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,22 +8,30 @@ import ( | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| var templateVarRe = regexp.MustCompile(`\{\{(\w+)\}\}`) | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| const scriptHeader = "#!/bin/bash" | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // GenerateScript wraps a body in a shebang header. | ||||||||||||||||||||||||||||||||||||||
| // GenerateScript returns the script body trimmed of surrounding whitespace with a trailing newline. | ||||||||||||||||||||||||||||||||||||||
| // No shebang is prepended — the executor adds a platform-appropriate shebang at execution time. | ||||||||||||||||||||||||||||||||||||||
| func GenerateScript(body string) string { | ||||||||||||||||||||||||||||||||||||||
| body = strings.TrimSpace(body) | ||||||||||||||||||||||||||||||||||||||
| return scriptHeader + "\n\n" + body + "\n" | ||||||||||||||||||||||||||||||||||||||
| if body == "" { | ||||||||||||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| return body + "\n" | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Preserve the persisted
Suggested fix func GenerateScript(body string) string {
body = strings.TrimSpace(body)
if body == "" {
return ""
}
- return body + "\n"
+ return "#!/bin/bash\n" + body + "\n"
}As per coding guidelines, "Scripts must be stored with #!/bin/bash shebang; the editor shows/edits the body without the shebang". 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // ParseScriptBody strips the shebang header and returns the user-editable body. | ||||||||||||||||||||||||||||||||||||||
| // ParseScriptBody strips any shebang line (#!...) from the beginning of stored script content. | ||||||||||||||||||||||||||||||||||||||
| // Handles both old format (scripts stored with #!/bin/bash in the DB) and new format | ||||||||||||||||||||||||||||||||||||||
| // (scripts stored without a shebang) transparently. | ||||||||||||||||||||||||||||||||||||||
| func ParseScriptBody(scriptContent string) string { | ||||||||||||||||||||||||||||||||||||||
| s := strings.TrimSpace(scriptContent) | ||||||||||||||||||||||||||||||||||||||
| if strings.HasPrefix(s, scriptHeader) { | ||||||||||||||||||||||||||||||||||||||
| s = strings.TrimPrefix(s, scriptHeader) | ||||||||||||||||||||||||||||||||||||||
| s = strings.TrimLeft(s, "\n") | ||||||||||||||||||||||||||||||||||||||
| if strings.HasPrefix(s, "#!") { | ||||||||||||||||||||||||||||||||||||||
| if idx := strings.Index(s, "\n"); idx != -1 { | ||||||||||||||||||||||||||||||||||||||
| s = s[idx+1:] | ||||||||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||||||||
| // Entire content is just a shebang line — no body | ||||||||||||||||||||||||||||||||||||||
| return "" | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
| return s | ||||||||||||||||||||||||||||||||||||||
| return strings.TrimSpace(s) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // ExtractTemplateVars returns unique variable names from {{var}} patterns, in order of first appearance. | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.