Files
filebrowser/backend/runner/parser.go
T
Graham Steffaniak b928e6557c updated with a few changes
- git directory structure changed (no more src folder)
 - search now works with filesize larger/smaller than x MB
 - search currently allows for only one search request at a time
   - cancels older requests by having them immediately return null
2023-07-21 17:41:24 -05:00

34 lines
676 B
Go

package runner
import (
"os/exec"
"github.com/gtsteffaniak/filebrowser/settings"
)
// ParseCommand parses the command taking in account if the current
// instance uses a shell to run the commands or just calls the binary
// directyly.
func ParseCommand(s *settings.Settings, raw string) ([]string, error) {
var command []string
if len(s.Shell) == 0 {
cmd, args, err := SplitCommandAndArgs(raw)
if err != nil {
return nil, err
}
_, err = exec.LookPath(cmd)
if err != nil {
return nil, err
}
command = append(command, cmd)
command = append(command, args...)
} else {
command = append(s.Shell, raw) //nolint:gocritic
}
return command, nil
}