No such file or directory error using "at:" property
darthpelo opened this issue · 3 comments
Today I tried to use the at
property to one of my script, but the result was always:
/bin/bash: line 0: cd: ~/foldername: No such file or directory
So I copied&pasted the example from the README.md file, just to figure out my error, but the result is the same:
import ShellOut
do {
try shellOut(to: ["mkdir NewFolder", "echo \"Hello again\" > NewFolder/File"])
let output = try shellOut(to: "cat File", at: "~/NewFolder")
print(output) // Hello again
}
catch {
let error = error as! ShellOutError
print(error.message) // Prints STDERR
print(error.output) // Prints STDOUT
}
/bin/bash: line 0: cd: ~/NewFolder: No such file or directory
.
I'm missing something?
My marathon is update (also ShellOut) and I use it a lot without any others issues :)
Thanks!
@darthpelo
I think you can not use ~
.
~
depends on running user.
Or, ShellOut may don't standardize path.
Please try to use an absolute path.
The problem is that ShellOut encloses the path passed using at:
in quotes, which causes cd
to fail to interpret it. The reason it does so is to support passing a path that contains spaces, but I think a better solution here would just be to escape the spaces.
Thanks @JohnSundell 👍