FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

A data-provider value ending in a backslash makes the argument disappear · Issue #1134 · TypedDevs/bashunit · GitHub

A data-provider value ending in a backslash makes the argument disappear #1134

Description

Problem

Provider values are unescaped shell-style before reaching the test, which is
defensible on its own — the parser has deliberate handling for \t, \n and
$'…' from printf '%q'. What is not defensible is the last row:

function provider_shapes() {
  echo 'plain'
  echo 'mid\dle'
  echo 'C:\'
  echo 'two\\back'
}
provider emits test receives
plain plain
mid\dle middle
C:\ <unset>
two\\back two\back

A value ending in a lone backslash does not arrive at all: ${1-<unset>} shows
the argument is unset, so the test runs against nothing and passes or fails for
a reason unrelated to the data. Silent, like the assert_equals backslash bug
reported today in #1108.

Windows paths (C:\), a trailing path separator, or a regex fragment ending in
an escape all hit it.

Where it is

bashunit::runner::parse_data_provider_args alone returns C: for that input —
the trailing backslash is dropped but the argument survives:

input=[C:\]                  -> arg=[C:]
input=[ends-with-backslash\] -> arg=[ends-with-backslash]

So the parser loses the backslash and something downstream loses the whole
argument. Both halves want fixing; the second is the user-visible one.

Nothing in docs/data-providers.md describes escape handling, so there is also
a question of what the intended contract is: literal values, or shell-unescaped
ones. Whichever it is, an argument silently vanishing is not it.

Activity

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

  • Status
    Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


Back | FazBrowse Home | New Git URL