MCPcopy
hub / github.com/filebrowser/filebrowser / ExampleSplitCommandAndArgs

Function ExampleSplitCommandAndArgs

runner/commands_test.go:276–303  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

274}
275
276func ExampleSplitCommandAndArgs() {
277 var commandLine string
278 var command string
279 var args []string
280
281 // just for the test - change GOOS and reset it at the end of the test
282 runtimeGoos = osWindows
283 defer func() {
284 runtimeGoos = runtime.GOOS
285 }()
286
287 commandLine = `mkdir /P "C:\Program Files"`
288 command, args, _ = SplitCommandAndArgs(commandLine)
289
290 fmt.Printf("Windows: %s: %s [%s]\n", commandLine, command, strings.Join(args, ","))
291
292 // set GOOS to linux
293 runtimeGoos = osLinux
294
295 commandLine = `mkdir -p /path/with\ space`
296 command, args, _ = SplitCommandAndArgs(commandLine)
297
298 fmt.Printf("Linux: %s: %s [%s]\n", commandLine, command, strings.Join(args, ","))
299
300 // Output:
301 // Windows: mkdir /P "C:\Program Files": mkdir [/P,C:\Program Files]
302 // Linux: mkdir -p /path/with\ space: mkdir [-p,/path/with space]
303}

Callers

nothing calls this directly

Calls 1

SplitCommandAndArgsFunction · 0.85

Tested by

no test coverage detected