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

How to pass files with spaces #480

Closed
olbrichj opened this issue Feb 1, 2018 · 3 comments
Closed

How to pass files with spaces #480

olbrichj opened this issue Feb 1, 2018 · 3 comments
Labels

Comments

@olbrichj
Copy link

olbrichj commented Feb 1, 2018

Hey,

when trying to index files with spaces I get either an "Illegal instruction: 4" or an empty return JSON.

Minimalistic example:
sourcekitten index --file "$(pwd)/Model/Test.swift" --compilerargs -- "$(pwd)/Model/Test.swift $(pwd)/Views/Class SpaceTest/SpaceTest.swift"
{

}

sourcekitten index --file "$(pwd)/Views/Class SpaceTest/SpaceTest.swift" --compilerargs -- "$(pwd)/Views/Class SpaceTest/SpaceTest.swift"
Illegal instruction: 4

As far as I can see it's not able to find the files.

I've already tried different approaches to escape the space. Including "" "\" "_" "-" using '' for the filename.

Do you know which is the right way to escape spaces?

@norio-nomura
Copy link
Collaborator

This is a bug of SourceKitten.
I filed a PR #481 that fixes this.

@olbrichj
Copy link
Author

olbrichj commented Feb 2, 2018

Great, thank you! Will I have to escape the spaces then? I guess "" will be necessary right?

@norio-nomura
Copy link
Collaborator

Either escape or double quote will be required.

$ echo 'print("space hello")'>space\ hello.swift
$ sourcekitten index --file "space hello.swift" --compilerargs -- "`pwd`/space hello.swift"
{
  "key.dependencies" : [
    {
      "key.filepath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/lib\/swift\/macosx\/x86_64\/Swift.swiftmodule",
      "key.hash" : "22NC2OR6IU6GZ",
      "key.is_system" : true,
      "key.kind" : "source.lang.swift.import.module.swift",
      "key.name" : "Swift"
    }
  ],
  "key.entities" : [
    {
      "key.column" : 1,
      "key.kind" : "source.lang.swift.ref.function.free",
      "key.line" : 1,
      "key.name" : "print(_:separator:terminator:)",
      "key.usr" : "s:s5printySayypGd_SS9separatorSS10terminatortF"
    }
  ],
  "key.hash" : "2PH1NRS6GZFLH"
}
$ sourcekitten index --file space\ hello.swift --compilerargs -- `pwd`/space\ hello.swift
{
  "key.dependencies" : [
    {
      "key.filepath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/lib\/swift\/macosx\/x86_64\/Swift.swiftmodule",
      "key.hash" : "22NC2OR6IU6GZ",
      "key.is_system" : true,
      "key.kind" : "source.lang.swift.import.module.swift",
      "key.name" : "Swift"
    }
  ],
  "key.entities" : [
    {
      "key.column" : 1,
      "key.kind" : "source.lang.swift.ref.function.free",
      "key.line" : 1,
      "key.name" : "print(_:separator:terminator:)",
      "key.usr" : "s:s5printySayypGd_SS9separatorSS10terminatortF"
    }
  ],
  "key.hash" : "2PH1NRS6GZFLH"
}

@jpsim jpsim closed this as completed in #481 Mar 7, 2018
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

2 participants