Skip to content

Path issues on linux based platforms using a forward slash (incl. Docker on Windows) #2

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

Open
knoll-nc opened this issue Apr 5, 2022 · 0 comments · May be fixed by #3
Open

Path issues on linux based platforms using a forward slash (incl. Docker on Windows) #2

knoll-nc opened this issue Apr 5, 2022 · 0 comments · May be fixed by #3

Comments

@knoll-nc
Copy link

knoll-nc commented Apr 5, 2022

When using the example/menu_script.ps1 on a linux based filesystem with forward slash for folder separation, the "ExitOption" will never be shown after leaving the starting folder of the menu tree.
This is most likely due to the code in line 33 "if ($current_menu_location -eq $menu_menu_dir) {" which will never be true once changing the menu, as $menu_menu_dir will have a backslash in its path while the $current_menu_location will have a forward slash.

As a result, the menu never shows ExitOption. It will crash once going higher in the menu tree than $menu_menu_dir.

As a solution I recommend to change the way the paths are built:
in /example/vars/menu_vars.ps1 the $menu_menu_dir is built like this, including a backslash:
$menu_menu_dir = $menu_script_root_dir + '\Example PowerShell CLI Menu' # The path to the menu structure

To work around the issue of a slash, the path should be build with Join-Path:
$menu_menu_dir = Join-Path -Path $menu_script_root_dir -ChildPath 'Example PowerShell CLI Menu' # The path to the menu structure

The issue was experienced and fix tested using it within a Docker container on Windows using WSL2.

As paths are built at different parts of the script maybe change all the build processes to Join-Path.

sebastianmanger added a commit that referenced this issue May 23, 2024
@sebastianmanger sebastianmanger linked a pull request May 23, 2024 that will close this issue
sebastianmanger added a commit that referenced this issue May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant