microsoft / dev-tunnels

Dev Tunnels SDK
MIT License
286 stars 20 forks source link

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

Closed tsuyoshi-kaneko-flect closed 1 month ago

tsuyoshi-kaneko-flect commented 5 months ago

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
derekbekoe commented 1 month ago

Thanks for taking the time to file this issue. Unfortunately, we’re not able to prioritize this issue over the other higher-impact issues we receive every week, based on the votes and comments from others in the community. Marking this as a known-issue.