Fix crash when read the config file#952
Conversation
|
We got some bug report in the bugzilla. |
|
I think a better answer is to read config from /usr/share/opencc (or equivalent), and only read from current directory if prefixed with "./" or "/" full path. I just wasn't expecting the "-c" argument to be interpreted relative to current. The input / output for sure look at the current directory, but the config files are supposedly fixed look-up tables, and I was not expecting opencc to read it from current directory first. |
|
I encountered the bug because I was making a new directory "s2t" for the converted output; and occasionally I run "opencc -c s2t ..." in its patent, unknowingly. Sometimes I run the command in a different directory, but often I create a sub-directory "s2t" for converted outputs, before filing them elsewhere. |
It sounds like an edge case. Not many people happen to have a local directory with the same basename. Changing the path finding logic isn't necessary to fix the crash and it won't be easy either since some downstream projects may be relying on the current behaviour. It deserves opening a separate issue if you want to continue the discussion. |
|
@epico Thanks for the fix. |
|
I agree the current behavior, looking for config in currrent directory, is probably used by some, more likely than mine (having an unrelated sub-dir which collides). But it would be nice to see how "-c config-arg" is processed in the help page, for example. I just assumed that it would be expanded to finding "/usr/share/opencc/config-arg.json" . For example, does it look for ./config-arg.json too? Or other additional extensions? |
it looks for the json file in the current working directory first, then in |
|
Thanks for the review! @lotem Sorry, I think I don't have the permission to merge this pull request. |
|
But it looks for "config-arg" without extension as a json? |
No description provided.