Skip to content

curl: named globs in output file name for upload glob references#21407

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/upload-output-glob
Closed

curl: named globs in output file name for upload glob references#21407
bagder wants to merge 1 commit into
masterfrom
bagder/upload-output-glob

Conversation

@bagder
Copy link
Copy Markdown
Member

@bagder bagder commented Apr 22, 2026

Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:

curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'

Verified by test 2014

@bagder bagder added cmdline tool feature-window A merge of this requires an open feature window labels Apr 22, 2026
@github-actions github-actions Bot added the tests label Apr 22, 2026
@bagder bagder force-pushed the bagder/upload-output-glob branch from 5a751c0 to 352ad26 Compare April 22, 2026 07:49
@bagder

This comment was marked as resolved.

@bagder bagder force-pushed the bagder/upload-output-glob branch from 352ad26 to cdf04b4 Compare May 12, 2026 07:47
@bagder bagder changed the title curl: support ![num] in output file name for upload glob references curl: named globs in output file name for upload glob references May 12, 2026
@bagder bagder force-pushed the bagder/upload-output-glob branch from cdf04b4 to c23613f Compare May 12, 2026 07:49
@bagder bagder marked this pull request as ready for review May 12, 2026 08:37
@bagder bagder requested a review from Copilot May 12, 2026 08:37
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support in the curl tool for using named glob parts from --upload-file (upload-file globbing) when expanding --output filenames (via #<name>), similar to existing named URL glob support. This enables generating per-upload response filenames even when the URL itself is not globbed.

Changes:

  • Extend glob_match_url() to optionally resolve named #<...> references from a second glob set (upload-file glob).
  • Update output filename setup to consider upload-file glob usage in addition to URL glob usage.
  • Add test coverage (test2014) and document the new capability in --upload-file and --output docs.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/data/test2014 New regression test verifying --output can reference a named glob from --upload-file.
tests/data/Makefile.am Registers the new test case.
src/tool_urlglob.h Updates glob_match_url() signature to accept a second glob pointer.
src/tool_urlglob.c Implements lookup of named glob references in the second glob list.
src/tool_operate.c Wires upload-file glob into output filename glob expansion.
docs/cmdline-opts/upload-file.md Documents referencing named upload-file globs in --output.
docs/cmdline-opts/output.md Documents referencing named upload-file globs in output templates.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tool_urlglob.c Outdated
Comment thread src/tool_operate.c Outdated
Comment thread src/tool_operate.c Outdated
Comment thread docs/cmdline-opts/upload-file.md Outdated
Comment thread docs/cmdline-opts/output.md Outdated
@bagder bagder force-pushed the bagder/upload-output-glob branch from 88a1320 to 3704111 Compare May 12, 2026 14:17
@bagder
Copy link
Copy Markdown
Member Author

bagder commented May 12, 2026

augment review

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented May 12, 2026

🤖 Augment PR Summary

Summary: This PR extends curl’s output filename glob substitution so that parts of a globbed upload filename can be referenced (via named globs) when using -o/--output.

Changes:

  • Documented named glob usage and added examples showing --upload-file/-T globs driving --output naming.
  • Updated setup_outfile() to expand output templates when either URL globbing or upload-file globbing is active.
  • Extended glob_match_url() to optionally look up named glob references in a second URLGlob (upload glob) when not found in the URL glob.
  • Updated the public declaration in tool_urlglob.h to match the new function signature.
  • Added regression test test2014 and wired it into the test list.

Testing: Verified by new test 2014 (upload with glob; output name based on upload glob).

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread src/tool_urlglob.c Outdated
Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:

    curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'

Verified by test 2014

Closes #21407
@bagder bagder force-pushed the bagder/upload-output-glob branch from 3704111 to 2e5263e Compare May 13, 2026 06:17
@bagder bagder closed this in 2238f09 May 13, 2026
@bagder bagder deleted the bagder/upload-output-glob branch May 13, 2026 08:08
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:

    curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'

Verified by test 2014

Closes curl#21407
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmdline tool feature-window A merge of this requires an open feature window tests

Development

Successfully merging this pull request may close these issues.

2 participants