Skip to content

fix(shell): avoid empty and repeated library path entries in env.sh - #397

Draft
Elvand-Lie wants to merge 1 commit into
WasmEdge:masterfrom
Elvand-Lie:fix/env-sh-library-path
Draft

Elvand-Lie wants to merge 1 commit into
WasmEdge:masterfrom
Elvand-Lie:fix/env-sh-library-path

Conversation

@Elvand-Lie

Copy link
Copy Markdown
Contributor

Which GitHub issue does this PR close?

Closes #396

Why is this needed?

Sourcing env.sh with an unset or empty library path adds a current directory search entry. Sourcing it again duplicates the WasmEdge library directory.

What does this PR change?

Guard LD_LIBRARY_PATH and DYLD_LIBRARY_PATH with the same containment pattern used for PATH, and add a separator only when the existing value is nonempty.

How has this been tested?

The new test in shell_test sources the rendered script in sh with unset, empty and preset values, once and twice, for Linux and a simulated Darwin branch. It fails on master and passes with the fix. Ubuntu 24.04 installation and loader checks were repeated with the fixed binary. Rust 1.99.1: cargo fmt, Clippy with warnings denied, cargo test (184 passed, 2 ignored), and ShellCheck passed.

Anything else?

The Darwin branch was exercised with a shell uname function on Linux; native macOS was not run.

Guard library paths before prepending and add a separator only for nonempty values. Exercise the rendered POSIX template with unset, empty and preset library paths.

Signed-off-by: Elvand Lie Nababan <elvandlie@gmail.com>
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 this pull request may close these issues.

env.sh adds an empty LD_LIBRARY_PATH entry and repeats the library directory on each source

1 participant