MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / IsInitScriptPath

Function IsInitScriptPath

pkg/util/fileutil/fileutil.go:211–243  ·  view source on GitHub ↗

IsInitScriptPath tries to determine if the input string is a path to a script rather than an inline script content.

(input string)

Source from the content-addressed store, hash-verified

209// IsInitScriptPath tries to determine if the input string is a path to a script
210// rather than an inline script content.
211func IsInitScriptPath(input string) bool {
212 if len(input) == 0 || strings.Contains(input, "\n") {
213 return false
214 }
215
216 if suspiciousPattern.MatchString(input) {
217 return false
218 }
219
220 if flagPattern.MatchString(input) {
221 return false
222 }
223
224 // Check for home directory path
225 if strings.HasPrefix(input, "~/") {
226 return true
227 }
228
229 // Path must be absolute (if not home directory)
230 if !filepath.IsAbs(input) {
231 return false
232 }
233
234 // Check if path starts with system binary directories
235 normalizedPath := filepath.ToSlash(input)
236 for _, binDir := range systemBinDirs {
237 if strings.HasPrefix(normalizedPath, binDir) {
238 return false
239 }
240 }
241
242 return true
243}
244
245const (
246 TempFileSuffix = ".tmp"

Callers 1

getCustomInitScriptFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected