peak/s5cmd

run input syntax is not documented

Opened this issue · 1 comments

As far as I can see there is no documentation except for the README.md file and it does not say anything about the syntax of the input to the s5cmd run command.

In particular it does not say anything about how to quote file/object names with whitespace or other special characters.

The relevant code snippet

s5cmd/command/run.go

Lines 105 to 147 in c1c7ee3

line = strings.TrimSpace(line)
if line == "" {
continue
}
// skip comment lines
if strings.HasPrefix(line, "#") {
continue
}
fields, err := shellquote.Split(line)
if err != nil {
return err
}
if len(fields) == 0 {
continue
}
if fields[0] == "run" {
err := fmt.Errorf("%q command (line: %v) is not permitted in run-mode", "run", lineno)
printError(commandFromContext(r.c), r.c.Command.Name, err)
continue
}
fn := func() error {
subcmd := fields[0]
cmd := AppCommand(subcmd)
if cmd == nil {
err := fmt.Errorf("%q command (line: %v) not found", subcmd, lineno)
printError(commandFromContext(r.c), r.c.Command.Name, err)
return nil
}
flagset := flag.NewFlagSet(subcmd, flag.ExitOnError)
if err := flagset.Parse(fields); err != nil {
printError(commandFromContext(r.c), r.c.Command.Name, err)
return nil
}
ctx := cli.NewContext(app, flagset, r.c)
return cmd.Run(ctx)

It appears that:

AFAIU: we can say that each line must be formatted so that running s5cmd {line} on the shell would work as intended. Except that the run command is not allowed to be called in this way.