microsoft/dev-tunnels

Install script for Linux doesn't work properly when $PATH includes spaces

tsuyoshi-kaneko-flect opened this issue · 1 comments

Environment

I'm running Ubuntu with WSL.

$ cat /etc/os-release
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

Description

Problem

I followed the instruction in https://learn.microsoft.com/ja-jp/azure/developer/dev-tunnels/get-started?tabs=linux to install devtuunel CLI and found the below section of the install script has a problem.

if [[ ":$PATH:" != *":$HOME/bin:"* ]]; then
    if [[ -e ~/.zshrc ]]; then
        echo "export PATH=$PATH:$HOME/bin" >> $HOME/.zshrc
        fileUsed="~/.zshrc"
    elif  [[ -e ~/.bashrc ]]; then
        echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bashrc
        fileUsed="~/.bashrc"
    else
        echo "export PATH=$PATH:$HOME/bin" >> $HOME/.bash_profile
        fileUsed="~/.bash_profile"
    fi
fi

This adds a line like export PATH=/home/tsuyoshi_kaneko/.local/bin:/mnt/c/Users/tsuyoshi.kaneko/AppData/Local/Programs/Microsoft VS Code/bin:/home/tsuyoshi_kaneko/bin to a dotfile. It is not properly executed because the value of PATH includes spaces and is not single-quoted.

Solution(my suggestion)

I think the problem can be solved by changing double-quotation of the echo section to single quotation like:

echo 'export PATH=$PATH:$HOME/bin' >> $HOME/.zshrc

or don't extract $PATH and $HOME:

echo "export PATH='$PATH:$HOME/bin'" >> $HOME/.zshrc