Skip to content

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

Open
@knoll-nc

Description

@knoll-nc

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions