2019-01-05 22:44:33 +00:00
|
|
|
package runner
|
|
|
|
|
|
|
|
|
|
import (
|
2020-06-01 01:12:36 +02:00
|
|
|
"github.com/filebrowser/filebrowser/v2/settings"
|
2019-01-05 22:44:33 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ParseCommand parses the command taking in account if the current
|
|
|
|
|
// instance uses a shell to run the commands or just calls the binary
|
2025-06-26 15:19:13 +02:00
|
|
|
// directly.
|
2025-06-26 21:09:16 +02:00
|
|
|
func ParseCommand(s *settings.Settings, raw string) (command []string, name string, err error) {
|
|
|
|
|
name, args, err := SplitCommandAndArgs(raw)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return
|
|
|
|
|
}
|
2019-01-05 22:44:33 +00:00
|
|
|
|
2024-08-30 15:24:45 -04:00
|
|
|
if len(s.Shell) == 0 || s.Shell[0] == "" {
|
2025-06-26 21:09:16 +02:00
|
|
|
command = append(command, name)
|
2019-01-05 22:44:33 +00:00
|
|
|
command = append(command, args...)
|
|
|
|
|
} else {
|
2025-06-27 08:03:11 +02:00
|
|
|
command = append(command, s.Shell...)
|
|
|
|
|
command = append(command, raw)
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-26 21:09:16 +02:00
|
|
|
return command, name, nil
|
2019-01-05 22:44:33 +00:00
|
|
|
}
|