Skip to content

Commit 4c20ebf

Browse files
committed
Add: permission x
1 parent c3bc7e4 commit 4c20ebf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

internal/leetcode/question_data.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package leetcode
33
import (
44
"bytes"
55
"fmt"
6+
"os"
67
"path"
78
"regexp"
89
"strings"
@@ -181,9 +182,12 @@ func (question questionType) SaveCodeSnippet() {
181182
}
182183
}
183184

184-
func (question questionType) saveCodeContent(content, ext string) {
185+
func (question questionType) saveCodeContent(content, ext string, permX ...bool) {
185186
filePath := question.getFilePath(question.TitleSnake() + ext)
186187
filePutContents(filePath, []byte(content))
188+
if len(permX) > 0 && permX[0] == true {
189+
os.Chmod(filePath, 0755)
190+
}
187191
}
188192

189193
func handleCodeGolang(question questionType, code codeSnippetsType) {
@@ -209,11 +213,11 @@ func handleCodeGolang(question questionType, code codeSnippetsType) {
209213
}
210214

211215
func handleCodeBash(question questionType, code codeSnippetsType) {
212-
question.saveCodeContent("#!/usr/bin/env bash\n\n"+code.Code, ".bash")
216+
question.saveCodeContent("#!/usr/bin/env bash\n\n"+code.Code, ".bash", true)
213217
}
214218

215219
func handleCodePython(question questionType, code codeSnippetsType) {
216-
question.saveCodeContent("#!/usr/bin/env python\n\n"+code.Code, ".py")
220+
question.saveCodeContent("#!/usr/bin/env python\n\n"+code.Code, ".py", true)
217221
}
218222

219223
func handleCodeSQL(question questionType, code codeSnippetsType) {

problems/tenth-line/tenth_line.bash

100644100755
File mode changed.

0 commit comments

Comments
 (0)