Skip to content

Commit

Permalink
command/run: drop inline comment support
Browse files Browse the repository at this point in the history
Previously s5cmd supported a command with an inline comment like `ls s3://bucket/object.gz  # inline comment` was supported.

Comment per line is still supported.

Fixes #309
  • Loading branch information
igungor committed Apr 6, 2022
1 parent e7c51f9 commit 40c765b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

## not released yet

#### Breaking changes
- Dropped inline comment feature for `run` command. Previously s5cmd supported a command with an inline comment like `ls s3://bucket/object.gz # inline comment` was supported. ([#309](https://github.com/peak/s5cmd/issues/309))

#### Features
- Added `--ignore-glacier-warnings` flag to `cp`, `mv` and `select` commands. ([#346](https://github.com/peak/s5cmd/issues/346))
- Added `--force-glacier-transfer` flag to `select` command. ([#404](https://github.com/peak/s5cmd/pull/404))
- Added `--force-glacier-transfer` flag to `select` command. ([#346](https://github.com/peak/s5cmd/issues/346))
- Added AWS Single Sign-On (SSO) profiles support ([#385](https://github.com/peak/s5cmd/issues/385))
- Added `--use-v1-api` flag to force using S3 ListObjects API instead of ListObjectsV2 API. ([#405](https://github.com/peak/s5cmd/issues/405)

Expand Down
4 changes: 1 addition & 3 deletions command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,12 @@ func (r Run) Run(ctx context.Context) error {
for line := range scanner.Scan() {
lineno++

// support inline comments
line = strings.Split(line, " #")[0]

line = strings.TrimSpace(line)
if line == "" {
continue
}

// skip comment lines
if strings.HasPrefix(line, "#") {
continue
}
Expand Down
5 changes: 3 additions & 2 deletions e2e/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ func TestRunFromStdin(t *testing.T) {

input := strings.NewReader(
strings.Join([]string{
fmt.Sprintf("ls s3://%v/file1.txt", bucket),
" # this is a comment",
fmt.Sprintf("ls s3://%v/file2.txt # this is an inline comment", bucket),
fmt.Sprintf("ls s3://%v/file1.txt", bucket),
"# this one too",
fmt.Sprintf("ls s3://%v/file2.txt", bucket),
}, "\n"),
)
cmd := s5cmd("run")
Expand Down

0 comments on commit 40c765b

Please sign in to comment.