Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globber exception when using a path with an exclamation #1323

Closed
stffabi opened this issue Oct 27, 2016 · 8 comments
Closed

Globber exception when using a path with an exclamation #1323

stffabi opened this issue Oct 27, 2016 · 8 comments
Labels
Milestone

Comments

@stffabi
Copy link
Contributor

stffabi commented Oct 27, 2016

What You Are Seeing?

Running a cake script in a folder containing an ! (exclamation) e.g. "C:\Some ! Directory" build.cake throws an exception, "Unknown token"

What is Expected?

Glober should allow to use exclamations in a path.

What version of Cake are you using?

v0.16.2

Are you running on a 32 or 64 bit system?

x64

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

TC, but also reproducable locally.

How Did You Get This To Happen? (Steps to Reproduce)

Running the following cake script in a folder with an exclamation, e.g. "C:\Some ! Directory"

Task("Test")
    .Does(() =>
{
    var SourceFolder = GetFiles(MakeAbsolute(Directory("./")).FullPath);
});

RunTarget("Test");

Output Log

Preparing to run build script...
Running build script...
Analyzing build script...
Processing build script...
Compiling build script...

========================================
Test
========================================
Executing task: Test
An error occured when executing task 'Test'.
Error: Unknown token
Press any key to continue . . .
@gep13
Copy link
Member

gep13 commented Oct 28, 2016

@stffabi thanks again!

@jnm2
Copy link
Contributor

jnm2 commented Nov 11, 2016

I wish I had seen this sooner. The fix you really want is to glob-escape it. The resulting glob should be \!. You'd run into this very same thing with any other globbing tool.
Now not only are your globs not portable to any other tool, it's impossible for Cake to implement the extremely useful negation operator without a breaking change.

@gep13
Copy link
Member

gep13 commented Nov 12, 2016

@jnm2 ah, I see. Feel free to raise another issue for discussion, and link back to this one.

@stffabi
Copy link
Contributor Author

stffabi commented Nov 12, 2016

@gep13 yes a discussion would be great about this. This also has impact on implementation of #1354. Unfortunately I haven't found any grammar information so far, didn't search for too long up to now. According to https://en.wikipedia.org/wiki/Glob_(programming), Glob allows to have ! only in [..]. This should still be possible to implement as brackets are still not valid in a identifier up to now. So I think ! outside of [..] don't need to be escaped.

@jnm2 refers to Extglob, which allows an additional syntax with pattern lists, https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html. In extglob one can use +, @ and ! in combination with a pattern list. All of these can't be implemented without a breaking change. At least + was supported for a long time in globtokenizer to be used in an identifier. The @ was also introduced in the 0.17 version of cake.

@jnm2 do you have a link to the grammar? The best basis for a discussion would be to have the grammar for glob/extglob.

@devlead
Copy link
Member

devlead commented Nov 12, 2016

As the globber is one of those pieces you can replace with a module, an alternative breaking way doesn't need to break the default for every Cake user out there, but could rather be an opt-in experience.
Going the contrib module path would also make it easier to do an PoC and compare default to new globber in a safe way out of band with Cake releases.

@jnm2
Copy link
Contributor

jnm2 commented Nov 12, 2016

@stffabi That is true. I assumed everyone would want to work with extglob, but if that's not the case, it could be turned on and off. I know that I for one am hoping to be able to share globs between TFS Build vNext (extglob) and Cake, but I wouldn't want to disrupt people who didn't want to use extglob.

Best grammar I can find is the bash man page under the Pattern Matching section.
https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html
edit: well if I didn't end up with the same link...

@devlead
Copy link
Member

devlead commented Nov 12, 2016

Well a new globbing paradigm in an external module would make that opt-in & risk free effort. Modules / addins that makes sense for Core/Common can always be promoted later into those in the future.

@jnm2
Copy link
Contributor

jnm2 commented Nov 12, 2016

I would hope that in the long term future, extglob would be supported OOB since C# developers (especially web developers) will be used to them from tooling across the board. AFAIK everything npm-based is extglob: grunt, gulp, etc.
I'm not sure of the demand for non-ext globs. To be fair though, I think .gitignore and .tfignore are simple globs with the added rule that ! at the first character of the line negates the entire pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants