View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0004067 | OpenFOAM | Bug | public | 2024-03-26 02:04 | 2024-03-27 19:55 |
Reporter | blackk100 | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | new | Resolution | open | ||
Platform | GNU/Linux WSL2 | OS | Ubuntu | OS Version | 22.04 |
Product Version | 11 | ||||
Summary | 0004067: Cleaned PATH eats up valid paths | ||||
Description | foamCleanPath considers whitespaces and colons as valid field separators, although Linux only specifies colons for splitting the actual paths (at least according to this https://www.linfo.org/path_env_var.html). This is especially an issue on WSL 2 as Windows appends its own PATH when installing the OS (in the form of /mnt/c/Program Files/...). This results in the user being unable to call Windows executables from the WSL OS (such as VS Code or explorer.exe). | ||||
Steps To Reproduce | Source etc/bashrc | ||||
Additional Information | This can be fixed easily if a copy of the PATH variable is made before souring etc/bashrc: win_path=$(sed "s|^$(sed "s|:/mnt.*$||g" <<< $PATH)||g" <<< $PATH) . /opt/openfoam11/etc/bashrc export PATH=$(sed "s|:/mnt.*$|$win_path|g" <<< $PATH) unset win_path | ||||
Tags | No tags attached. | ||||
|
This is an update to the workaround to deal with regex metacharacters in the PATH. This also assumes that the first mount point in the PATH is located after any OpenFOAM paths, and is run in bash. path_wsl=$(sed 's|:/mnt.*||' <<< $PATH) path_wsl=$(sed -e 's|\^|\\\^|g' -e 's|\$|\\\$|g' -e 's|\*|\\\*|g' -e 's|\+|\\\+|g' -e 's|\?|\\\?|g' -e 's|\.|\\\.|g' <<< $path_wsl) path_win=$(sed "s|^$path_wsl||" <<< $PATH) . /opt/openfoam11/etc/bashrc path_wsl=$(sed 's|:/mnt.*||' <<< $PATH) export PATH="$path_wsl$path_win" unset path_wsl path_win |