summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAlireza Bahrami <[email protected]>2025-06-14 06:58:33 +0330
committerGitHub <[email protected]>2025-06-13 23:28:33 -0400
commitec928d88b5133dedf7414a60ff2fb284024636e1 (patch)
tree11dbf2d757a678961c2ae461de390dc077edf3cd
parent59a5f120c040e5738731ffd4af8e19a1c603fff6 (diff)
downloadopencode-ec928d88b5133dedf7414a60ff2fb284024636e1.tar.gz
opencode-ec928d88b5133dedf7414a60ff2fb284024636e1.zip
fix(install): check if the path export command already exists (#28)
-rwxr-xr-xinstall5
1 files changed, 4 insertions, 1 deletions
diff --git a/install b/install
index 33bca14d9..e18bd7bbf 100755
--- a/install
+++ b/install
@@ -107,7 +107,9 @@ add_to_path() {
local config_file=$1
local command=$2
- if [[ -w $config_file ]]; then
+ if grep -Fxq "$command" "$config_file"; then
+ print_message info "Command already exists in $config_file, skipping write."
+ elif [[ -w $config_file ]]; then
echo -e "\n# opencode" >> "$config_file"
echo "$command" >> "$config_file"
print_message info "Successfully added ${ORANGE}opencode ${GREEN}to \$PATH in $config_file"
@@ -173,6 +175,7 @@ if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH"
;;
*)
+ export PATH=$INSTALL_DIR:$PATH
print_message warning "Manually add the directory to $config_file (or similar):"
print_message info " export PATH=$INSTALL_DIR:\$PATH"
;;