From 010d2899b3ac9057ae987da4b59cff7c992e588e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:39:06 +0000 Subject: [PATCH] Fix unquoted variables in all shell scripts to prevent word splitting Co-authored-by: andrejusk <7396847+andrejusk@users.noreply.github.com> --- files/home/.profile | 2 +- files/home/.zshrc | 4 ++-- script/install | 6 +++--- script/install.d/01-ssh.sh | 8 ++++---- script/install.d/05-zsh.sh | 4 ++-- script/install.d/06-stow.sh | 18 +++++++++--------- script/install.d/10-pyenv.sh | 4 ++-- script/install.d/11-python.sh | 4 ++-- script/install.d/97-macos.sh | 4 ++-- 9 files changed, 27 insertions(+), 27 deletions(-) diff --git a/files/home/.profile b/files/home/.profile index aacd3d9..8a05ea7 100644 --- a/files/home/.profile +++ b/files/home/.profile @@ -36,7 +36,7 @@ _dots_load_nvm node_alias="$NVM_DIR/alias/lts/jod" if [ -f "$node_alias" ]; then - VERSION=`cat $node_alias` + VERSION=`cat "$node_alias"` node_bin_path="$NVM_DIR/versions/node/$VERSION/bin" if [[ ":$PATH:" != *":$node_bin_path:"* ]]; then export PATH="$node_bin_path:$PATH" diff --git a/files/home/.zshrc b/files/home/.zshrc index 2885001..4970192 100644 --- a/files/home/.zshrc +++ b/files/home/.zshrc @@ -7,7 +7,7 @@ fi # Load profile # ----------------------------------------------------------------------------- _dots_load_profile() { - source $HOME/.profile + source "$HOME/.profile" } _dots_load_profile @@ -21,7 +21,7 @@ _dots_load_omz() { zsh-autosuggestions zsh-syntax-highlighting ) - source $ZSH/oh-my-zsh.sh + source "$ZSH/oh-my-zsh.sh" } _dots_load_omz diff --git a/script/install b/script/install index 9ee9070..d4a560a 100755 --- a/script/install +++ b/script/install @@ -81,18 +81,18 @@ run() { for script in $install_dir/*.sh; do if [[ -n "$targets" ]]; then - script_name=$(basename $script .sh) + script_name=$(basename "$script" .sh) script_name=${script_name#*-} if [[ ! " ${targets[*]} " =~ " $script_name " ]]; then continue fi fi - local script_name=$(basename $script) + local script_name=$(basename "$script") printf "\n\n${CYAN}<<< ${CYAN_BOLD}$script_name:${NC}\n" local start_time=$(date +%s.%N) - source $script + source "$script" local end_time=$(date +%s.%N) local execution_time=$(echo "$end_time - $start_time" | bc) local execution_ms=$(echo "$execution_time * 1000" | bc | awk '{printf "%.0f", $0}') diff --git a/script/install.d/01-ssh.sh b/script/install.d/01-ssh.sh index 4c3c6c0..41b5080 100644 --- a/script/install.d/01-ssh.sh +++ b/script/install.d/01-ssh.sh @@ -18,14 +18,14 @@ if [ -z "$SKIP_SSH_CONFIG" ]; then ssh_target="${HOME}/.ssh" ssh_key="${ssh_target}/id_${ssh_method}" ssh_pub="${ssh_key}.pub" - if [ ! -f $ssh_key ]; then + if [ ! -f "$ssh_key" ]; then ssh-keygen \ - -t $ssh_method \ - -f $ssh_key \ + -t "$ssh_method" \ + -f "$ssh_key" \ -C "$(whoami)@$(hostname)-$(date -I)" fi - cat $ssh_pub + cat "$ssh_pub" unset ssh_method ssh_target ssh_key ssh_pub else diff --git a/script/install.d/05-zsh.sh b/script/install.d/05-zsh.sh index 6fdaacc..2e4ae2b 100644 --- a/script/install.d/05-zsh.sh +++ b/script/install.d/05-zsh.sh @@ -29,7 +29,7 @@ export ZSH_SYNTAX_HIGHLIGHTING="$ZSH_CUSTOM/plugins/zsh-syntax-highlighting" if [ ! -d "$ZSH_SYNTAX_HIGHLIGHTING" ]; then git clone -q \ https://github.com/zsh-users/zsh-syntax-highlighting.git \ - $ZSH_SYNTAX_HIGHLIGHTING + "$ZSH_SYNTAX_HIGHLIGHTING" fi # install zsh-autosuggestions @@ -37,7 +37,7 @@ export ZSH_AUTOSUGGESTIONS="$ZSH_CUSTOM/plugins/zsh-autosuggestions" if [ ! -d "$ZSH_AUTOSUGGESTIONS" ]; then git clone -q \ https://github.com/zsh-users/zsh-autosuggestions.git \ - $ZSH_AUTOSUGGESTIONS + "$ZSH_AUTOSUGGESTIONS" fi # change default shell to zsh diff --git a/script/install.d/06-stow.sh b/script/install.d/06-stow.sh index 09a2250..8a909c4 100644 --- a/script/install.d/06-stow.sh +++ b/script/install.d/06-stow.sh @@ -17,16 +17,16 @@ stow --version root_dir=${DOTFILES:-$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")} -rm -f $HOME/.bash_profile -rm -f $HOME/.bashrc -rm -f $HOME/.gitconfig -rm -f $HOME/.profile -rm -f $HOME/.zshrc -rm -f $HOME/.p10k.zsh -rm -f $HOME/.ssh/config +rm -f "$HOME/.bash_profile" +rm -f "$HOME/.bashrc" +rm -f "$HOME/.gitconfig" +rm -f "$HOME/.profile" +rm -f "$HOME/.zshrc" +rm -f "$HOME/.p10k.zsh" +rm -f "$HOME/.ssh/config" -mkdir -p $HOME/.config -mkdir -p $HOME/.ssh +mkdir -p "$HOME/.config" +mkdir -p "$HOME/.ssh" stow --dir="$root_dir/files" --target="$HOME" home stow --dir="$root_dir/files" --target="$HOME/.config" dot-config diff --git a/script/install.d/10-pyenv.sh b/script/install.d/10-pyenv.sh index e26e7b7..b117408 100644 --- a/script/install.d/10-pyenv.sh +++ b/script/install.d/10-pyenv.sh @@ -6,7 +6,7 @@ # export PYENV_ROOT="$HOME/.pyenv" -if ! echo $PATH | grep -q "$PYENV_ROOT"; then +if ! echo "$PATH" | grep -q "$PYENV_ROOT"; then export PATH="$PYENV_ROOT/bin:$PATH" fi if ! command -v pyenv &>/dev/null; then @@ -31,7 +31,7 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then if [ ! -d "$virtualenv_path" ]; then git clone \ https://github.com/pyenv/pyenv-virtualenv.git \ - $virtualenv_path + "$virtualenv_path" fi unset virtualenv_path fi diff --git a/script/install.d/11-python.sh b/script/install.d/11-python.sh index 1937c1c..62f26e8 100644 --- a/script/install.d/11-python.sh +++ b/script/install.d/11-python.sh @@ -56,6 +56,6 @@ poetry --version POETRY_PLUGIN="$ZSH/custom/plugins/poetry" if [ ! -d "$POETRY_PLUGIN" ]; then - mkdir -p $POETRY_PLUGIN - poetry completions zsh > $POETRY_PLUGIN/_poetry + mkdir -p "$POETRY_PLUGIN" + poetry completions zsh > "$POETRY_PLUGIN/_poetry" fi diff --git a/script/install.d/97-macos.sh b/script/install.d/97-macos.sh index c2be01c..507d396 100644 --- a/script/install.d/97-macos.sh +++ b/script/install.d/97-macos.sh @@ -173,9 +173,9 @@ if [[ "$OSTYPE" == "darwin"* ]]; then path="${dock_order[$i]}" name=$(basename "$path" | sed 's/\.app$//') if [[ $dock_state == *"$name"* ]]; then - dockutil --move "${path}" --position $i --no-restart + dockutil --move "${path}" --position "$i" --no-restart else - dockutil --add "${path}" --position $i --no-restart + dockutil --add "${path}" --position "$i" --no-restart fi fi done