Skip to content

Exit code 0 on failure #1190

@bazzilic

Description

@bazzilic

In certain scenarios, error state produces an exit code 0, which makes it hard to write scripts with proper error handling.
In particular, if access to the destination path is denied, s3cmd would fail with exit code 0:

C:\Users\bazzilic> wsl s3cmd get s3://XXX/abc.plt /d/abc/abc.plt
ERROR: Skipping /d/abc/abc.plt: Permission denied

C:\Users\bazzilic> $LASTEXITCODE
0

This is not a WSL quirk, in other instances there is a proper exit code on error:

C:\Users\bazzilic> wsl s3cmd asdflkj asdlkfjh
ERROR: Invalid command: asdflkj

C:\Users\bazzilic> $LASTEXITCODE
64

Version of s3cmd:

C:\Users\bazzilic> wsl s3cmd --version
s3cmd version 2.0.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions