Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run input syntax is not documented #713

Open
PerMildner opened this issue Mar 18, 2024 · 1 comment
Open

run input syntax is not documented #713

PerMildner opened this issue Mar 18, 2024 · 1 comment

Comments

@PerMildner
Copy link

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.

@kucukaslan
Copy link
Contributor

kucukaslan commented Mar 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants