You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
urlnum is documented as The URL index number of this transfer, 0-indexed.
curl/libcurl version
Since it was added in 7.75.0
analysis
struct getoutnum is the 0-indexed URL number from the command line. struct Stateurlnum is the 1-indexed number of the currently parsed globbed URL or 1 if not globbed.
The glob state of the current URL is also kept track of via State.li which is checked to reset the glob state and force reglob (but just skimming this I don't understand why that is necessary).
In single_transfer State.urlnum is assigned to a local urlnum, and shortly after getout.num is assigned to per_transfer urlnum.
It appears the only purpose of the per_transfer.urlnum is to save the url number for the write-out variable %{urlnum}.
In order to fix this we'd have to keep track of the cumulative URL count from globbing previous URLs.
For example httpbin.org/get/[1-2] httpbin.org/get/[3-4] httpbin.org/get/5 deglobs to:
I don't think the index should include globbing, simply because it makes it really hard to understand which URL it referss to when for example the first URL uses globing and the second doesn't.
I did this
Коваленко Анатолий Викторович reported on the curl-library mailing list that
%{urlnum}
does not increment for globbed URLs. For example:I expected the following
urlnum is documented as
The URL index number of this transfer, 0-indexed.
curl/libcurl version
Since it was added in 7.75.0
analysis
struct getout
num
is the 0-indexed URL number from the command line.struct State
urlnum
is the 1-indexed number of the currently parsed globbed URL or 1 if not globbed.The glob state of the current URL is also kept track of via
State.li
which is checked to reset the glob state and force reglob (but just skimming this I don't understand why that is necessary).In single_transfer
State.urlnum
is assigned to a local urlnum, and shortly aftergetout.num
is assigned to per_transfer urlnum.It appears the only purpose of the
per_transfer.urlnum
is to save the url number for the write-out variable%{urlnum}
.In order to fix this we'd have to keep track of the cumulative URL count from globbing previous URLs.
For example
httpbin.org/get/[1-2] httpbin.org/get/[3-4] httpbin.org/get/5
deglobs to:httpbin.org/get/1
state->urlnum: 2
local urlnum: 2
state->li: 0
per->urlnum: 0
(expected) per->urlnum: 0
httpbin.org/get/2
state->urlnum: 2
local urlnum: 2
state->li: 1
per->urlnum: 0
(expected) per->urlnum: 1
httpbin.org/get/3
state->urlnum: 2
local urlnum: 2
state->li: 0
per->urlnum: 1
(expected) per->urlnum: 2
httpbin.org/get/4
state->urlnum: 2
local urlnum: 2
state->li: 1
per->urlnum: 1
(expected) per->urlnum: 3
httpbin.org/get/5
state->urlnum: 1
local urlnum: 1
state->li: 0
per->urlnum: 2
(expected) per->urlnum: 4
The text was updated successfully, but these errors were encountered: