From 31c29fa9c43d7fb5948aff31f0f5238fd341cba4 Mon Sep 17 00:00:00 2001 From: bsouza Date: Thu, 12 Sep 2024 16:51:42 +0000 Subject: [PATCH] Fix check for shell completion Signed-off-by: bsouza --- jfrog-token/run.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/jfrog-token/run.sh b/jfrog-token/run.sh index 52b3513..d2113d9 100644 --- a/jfrog-token/run.sh +++ b/jfrog-token/run.sh @@ -96,20 +96,19 @@ echo "📦 Configuring JFrog CLI completion..." SHELLNAME=$(grep "^$USER" /etc/passwd | awk -F':' '{print $7}' | awk -F'/' '{print $NF}') # Generate the completion script jf completion $SHELLNAME --install +begin_stanza="# BEGIN: jf CLI shell completion (added by coder module jfrog-token)" # Add the completion script to the user's shell profile if [ "$SHELLNAME" == "bash" ] && [ -f ~/.bashrc ]; then - if ! grep -q "# jf CLI shell completion" ~/.bashrc; then - echo "" >> ~/.bashrc - echo "# BEGIN: jf CLI shell completion (added by coder module jfrog-token)" >> ~/.bashrc + if ! grep -q "$begin_stanza" ~/.bashrc; then + printf "%s\n" "$begin_stanza" >> ~/.bashrc echo 'source "$HOME/.jfrog/jfrog_bash_completion"' >> ~/.bashrc echo "# END: jf CLI shell completion" >> ~/.bashrc else echo "🥳 ~/.bashrc already contains jf CLI shell completion configuration, skipping." fi elif [ "$SHELLNAME" == "zsh" ] && [ -f ~/.zshrc ]; then - if ! grep -q "# jf CLI shell completion" ~/.zshrc; then - echo "" >> ~/.zshrc - echo "# BEGIN: jf CLI shell completion (added by coder module jfrog-token)" >> ~/.zshrc + if ! grep -q "$begin_stanza" ~/.zshrc; then + printf "\n%s\n" "$begin_stanza" >> ~/.zshrc echo "autoload -Uz compinit" >> ~/.zshrc echo "compinit" >> ~/.zshrc echo 'source "$HOME/.jfrog/jfrog_zsh_completion"' >> ~/.zshrc