Win We should use %~dp0 not %CD%
#1
Question 
I ran into the following error when I was running some of the setup scripts
Code:
The system cannot find the path specified.
. The problem was that I was running the scripts from the package root, like I usually do. I had already ran some of the scripts correctly before, so I was confused as to why they weren't working now. After looking through the code I found that our .bat files are all using %CD% to get the current directory, instead of %~dp0.

I believe in the majority of cases, we should be using %~dp0, and referencing any paths from the location of the actual batch file, instead of %CD%, which is the actual current directory of the script's scope.. so either the location of the directory the script was ran from, or whatever directory the script is now being ran in (i.e. after running cd inside of the script, or in sub scripts..)

I was planning to put a pull request together fixing all of the batch scripts, but I decided I would post here first to make sure that I wasn't missing anything and to get help with any edge-cases I should be testing for.

You can read more about %cd% vs %~dp0 here http://www.computerhope.com/forum/index....ic=54333.0
Reply
#2
Pull request is very welcome, you're entirely correct that we should not rely on %CD%. It's most likely that the original author didn't know about dp0 and nobody really wants to touch batch files so it's just stayed there as it's mostly been working
The janitor, cleaner of cruft, defender of style. Also known as the unfunny guy that doesn't understand signatures.
Reply
#3
Excellent. I will get a pull request out soon and link it here. Thanks for the quick response.
Reply
#4
If anyone is wondering what's taking me so long, I'm trying to make sure I can get Kodi to build first before I go fiddling with the build scripts.
Reply

Logout Mark Read Team Forum Stats Members Help
We should use %~dp0 not %CD%1