Skip to content
This repository was archived by the owner on Dec 29, 2021. It is now read-only.
This repository was archived by the owner on Dec 29, 2021. It is now read-only.

assert_cmd! unexpected behaviour, which might eat your laundry #22

Closed
@colin-kiegel

Description

@colin-kiegel

This morning I made the following observation:

  • assert_cmd!(rm foo.bar) is equivalent to assert_cmd!(rm foo . bar).

See simplified Playground example. This is due to current limitations of the macro system. Macros can not access information about whitespaces. Period.

But quotations #15 won't work as expected either assert_cmd!(rm "foo.bar") will run rm "\"foo.bar\"".

rm: cannot remove '"foo.bar"': No such file or directory

This turns out to be way more problematic than initially thought...
Interpreting arguments as expressions is also problematic.

  • In this world assert_cmd!(rm "foo.bar") would work
  • but assert_cmd!(rm foo) could have serious side effects, e.g. if let foo = "/ -r"

This situation doesn't look good at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions