-
Notifications
You must be signed in to change notification settings - Fork 56
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
File paths on MacOS with ~ is not recognized as HOME #173
Comments
It already does. It works fine for Linux, so someone with a MacOS has to figure out why this doesn't work:
|
Hi @DanielGavin Thought I would try to help with this bug report as I use Odin and macOS. I tested the above suggested code on macOS and found the code suggested does not work as expected. It does not work on Linux ( The example output from the test code below on both macOS and Linux is: % odin run dir_test.odin -file
example path: '~/.Odin'
checking 'forward_path[0]': '126' [~]
env HOME is: '/Users/simon'
Orignal OLS code - updated 'forward_path' is: '~/.Odin'
New code - updated 'forward_path' is: '/Users/simon/.Odin' Example code used to test: // run with: odin run dir_test.odin -file
package main
import "core:fmt"
import "core:strings"
import "core:os"
main :: proc() {
// create an example path to test in macOS
forward_path : string = "~/.Odin"
fmt.printf("\nexample path: '%s'\n",forward_path)
// Lines below extract from: ols/src/server/requests.odin lines 515-530
// with additional 'fmt.printf' statements added.
//
//Support a basic use of '~'
when ODIN_OS != .Windows {
fmt.printf("checking 'forward_path[0]': '%v' [%c]\n",forward_path[0],i32(forward_path[0]))
if forward_path[0] == '~' {
home := os.get_env(
"HOME",
context.temp_allocator,
)
fmt.printf("env HOME is: '%s'\n",home)
strings.replace(
forward_path,
"~",
home,
1,
context.temp_allocator,
)
fmt.printf("Orignal OLS code - updated 'forward_path' is: '%s'\n",forward_path)
//
// new code below - capture the 'replace' proc returned value
forward_path, _ := strings.replace(
forward_path,
"~",
home,
1,
context.temp_allocator,
)
fmt.printf("New code - updated 'forward_path' is: '%s'\n",forward_path)
}
}
} Odin version used:
I could not see how to find the OLS version being used - but the last update made was:
Do you want me to create a PR with the above change to fix the use of Hope that helps :) Simon |
Thanks Simon. I can make the small change. Yeah I forgot to assign after the replace. |
The code has been pushed. |
That's great @DanielGavin - glad it was useful. |
When using ols.json to specify core and vendor library locations, I found that ols does not recognize the ~ as the HOME environment variable and [LS] autocomplete ceased to work.
I am using Neo-Vim and CoC.
I think that on MacOS ols should do a string replace for ~ with HOME.
The text was updated successfully, but these errors were encountered: