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

GetDirectories call fails when pattern contains certain characters #1656

Closed
patridge opened this issue Jun 23, 2017 · 3 comments
Closed

GetDirectories call fails when pattern contains certain characters #1656

patridge opened this issue Jun 23, 2017 · 3 comments

Comments

@patridge
Copy link
Contributor

This may end up being a request for documentation more than an issue, but I don't know enough about the Globber syntax to know if this is an obvious problem.

What You Are Seeing?

While abusing GetDirectories to get a full directory listing (see this SO question), I ran into cases where certain pattern parameters would case the script execution to fail with an error.

Error: Unknown token

Ignoring that there are better ways to get a directory listing (see the other workaround using System.IO), the error didn't make sense to me given what I could gather from the docs.

What is Expected?

Since the documentation on GetDirectories only has an example with ., **, and * in the pattern, I would expect all other characters to be valid characters to look for a match in the path itself. Again, I don't know if globbing has some pre-defined syntax I should research instead. Maybe a link to some standard on that API page would be a better solution.

What version of Cake are you using?

v0.20.0 (according to pakcages.config)

Are you running on a 32 or 64 bit system?

64-bit

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

Windows

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

No

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

For example, given this structure...

"script directory" (contains executing Cake script)
- "sub directory 1"
  - "sub sub dir"
- "sub directory #2"
  - "sub sub dir"
- "sub direct'ry 3"
  - "sub sub dir"

Running these commands to get the "sub sub" directories will fail

GetDirectories(@".\sub directory #2\*");
GetDirectories(@".\sub direct'ry 3\*");

Output Log

Normal log

Compiling build script...

========================================
GlobIssueRepro
========================================
Executing task: GlobIssueRepro
An error occurred when executing task 'GlobIssueRepro'.
Error: System.NotSupportedException: Unknown token
   at Cake.Core.IO.Globbing.GlobTokenizer.ScanToken()
   at Cake.Core.IO.Globbing.GlobTokenizer.Scan()
   at Cake.Core.IO.Globbing.GlobParserContext.Accept(GlobTokenKind[] kind)
   at Cake.Core.IO.Globbing.GlobParser.ParseSubSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.ParseSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
   at Cake.Core.IO.Globber.Match(String pattern, Func`2 predicate)
   at Cake.Common.IO.GlobbingAliases.GetDirectories(ICakeContext context, String pattern)
   at Submission#0.GetDirectories(String pattern)
   at Submission#0.<.ctor>b__0()
   at Cake.Core.ActionTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, String target)
   at Cake.Scripting.BuildScriptHost.RunTarget(String target)
   at Submission#0..ctor(Session session, Object& submissionResult)
   at Submission#0.<Factory>(Session session)
   at Roslyn.Scripting.CommonScriptEngine.Execute[T](String code, String path, DiagnosticBag diagnostics, Session session, Boolean isInteractive)
   at Roslyn.Scripting.Session.Execute(String code)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()

Experimental log

Compiling build script...

========================================
GlobIssueRepro
========================================
Executing task: GlobIssueRepro
An error occurred when executing task 'GlobIssueRepro'.
Error: System.NotSupportedException: Unknown token
   at Cake.Core.IO.Globbing.GlobTokenizer.ScanToken()
   at Cake.Core.IO.Globbing.GlobTokenizer.Scan()
   at Cake.Core.IO.Globbing.GlobParserContext.Accept(GlobTokenKind[] kind)
   at Cake.Core.IO.Globbing.GlobParser.ParseSubSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.ParseSegment(GlobParserContext context)
   at Cake.Core.IO.Globbing.GlobParser.Parse(GlobParserContext context)
   at Cake.Core.IO.Globber.Match(String pattern, Func`2 predicate)
   at Cake.Common.IO.GlobbingAliases.GetDirectories(ICakeContext context, String pattern)
   at Submission#0.GetDirectories(String pattern)
   at Submission#0.<.ctor>b__376_0()
   at Cake.Core.ActionTask.Execute(ICakeContext context)
   at Cake.Core.DefaultExecutionStrategy.Execute(CakeTask task, ICakeContext context)
   at Cake.Core.CakeEngine.ExecuteTask(ICakeContext context, IExecutionStrategy strategy, Stopwatch stopWatch, CakeTask task, CakeReport report)
   at Cake.Core.CakeEngine.RunTarget(ICakeContext context, IExecutionStrategy strategy, String target)
   at Cake.Scripting.BuildScriptHost.RunTarget(String target)
   at Submission#0..ctor(Object[] submissionArray, Object& submissionResult)
   at Submission#0.<Factory>(Object[] submissionArray)
   at Microsoft.CodeAnalysis.Scripting.ScriptExecutionState.RunSubmission(Func`2 submissionRunner)
   at Microsoft.CodeAnalysis.Scripting.Script.Run(Object globals)
   at Microsoft.CodeAnalysis.Scripting.Script.Run(Object globals)
   at Cake.Scripting.Roslyn.Nightly.DefaultRoslynNightlyScriptSession.Execute(Script script)
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath, IDictionary`2 arguments)
   at Cake.Commands.BuildCommand.Execute(CakeOptions options)
   at Cake.CakeApplication.Run(CakeOptions options)
   at Cake.Program.Main()
@devlead
Copy link
Member

devlead commented Jun 23, 2017

Probably related to what #1611 aims to solve

@SIkebe
Copy link
Contributor

SIkebe commented Jun 23, 2017

This issue is a duplicate of #1422

@devlead
Copy link
Member

devlead commented Oct 1, 2017

Fixed by #1611

@devlead devlead closed this as completed Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants