diff --git a/install.sh b/install.sh index 6a3f1d1..4fb6e79 100755 --- a/install.sh +++ b/install.sh @@ -1024,10 +1024,16 @@ main() { start_note=" started: $SERVICE_NAME.service" if [ "$INSTALL_MODE" = "user" ]; then start_note=" started: brig-containerd.service (systemd --user)" + # The line is for a startup file, so it says $HOME as written there. That + # also keeps a home path with a quote or a $ in it from breaking the line. + line_dir="$LAUNCH_DIR" + case "$LAUNCH_DIR" in + "$HOME"/*) line_dir="\$HOME${LAUNCH_DIR#"$HOME"}" ;; + esac case ":$PATH:" in - *":$LAUNCH_DIR:"*) ;; + *":$LAUNCH_DIR:"* | *":$LAUNCH_DIR/:"*) ;; *) grp_note=" path: $LAUNCH_DIR is not on your PATH. Add it to run brig by name: - export PATH=\"$LAUNCH_DIR:\$PATH\" + export PATH=\"$line_dir:\$PATH\" Put that line in your shell's startup file to keep it. Do not add $BIN_DIR: the brig there runs without the launcher's environment. " ;; diff --git a/tests/install-summary.sh b/tests/install-summary.sh index b86435d..c49c392 100644 --- a/tests/install-summary.sh +++ b/tests/install-summary.sh @@ -71,8 +71,23 @@ ok "the summary names the bundle and its version" # The line to type, since the only other full paths on screen are under the # tree's bin directory, and a brig run from there has no launcher environment. -grep -qF "export PATH=\"$T/home/.local/bin:\$PATH\"" "$T/out.log" \ - || { cat "$T/out.log" >&2; fail "the summary does not give the PATH line"; } +# shellcheck disable=SC2016 +grep -qF 'export PATH="$HOME/.local/bin:$PATH"' "$T/out.log" \ + || { cat "$T/out.log" >&2; fail "the summary does not give the PATH line as a startup file has it"; } grep -qF "Do not add $T/home/.local/share/brig/data/bin:" "$T/out.log" \ || { cat "$T/out.log" >&2; fail "the summary does not warn off the tree's bin directory"; } ok "the summary gives the PATH line" + +# A PATH entry written with a trailing slash is the same directory. +if ! env -u XDG_CONFIG_HOME -u XDG_DATA_HOME \ + HOME="$T/home" XDG_RUNTIME_DIR="$T/run" PATH="$T/stub:$T/home/.local/bin/:$PATH" \ + INSTALL_BRIG_BUNDLE="$T/bundle.tar.gz" \ + sh "$here/install.sh" > "$T/out2.log" 2>&1; then + cat "$T/out2.log" >&2 + fail "the second install failed" +fi +if grep -q "is not on your PATH" "$T/out2.log"; then + cat "$T/out2.log" >&2 + fail "a PATH with the launcher directory and a trailing slash was told to add it" +fi +ok "a trailing slash on the PATH entry counts"