@@ -63,15 +63,17 @@ debug_print "Detecting OS and architecture"
6363debug_print " uname -s output: $( uname -s) "
6464debug_print " uname -m output: $( uname -m) "
6565
66- if uname -s | grep -q -E -i " (cygwin|mingw|msys|windows)" ; then
66+ UNAME_S=$( uname -s)
67+ if echo " $UNAME_S " | grep -q -E -i " (cygwin|mingw|msys|windows)" ; then
6768 CLI_OS=" windows"
6869 ARCH=" amd64"
6970 FILE_NAME=" ${FILE_NAME} .exe"
7071 debug_print " Detected Windows OS"
71- elif uname -s | grep -q -i " darwin" ; then
72+ elif echo " $UNAME_S " | grep -q -i " darwin" ; then
7273 CLI_OS=" darwin"
7374 debug_print " Detected Darwin/macOS"
74- if [ " $( uname -m) " = " arm64" ]; then
75+ UNAME_M=$( uname -m)
76+ if [ " $UNAME_M " = " arm64" ]; then
7577 ARCH=" arm64"
7678 debug_print " Detected ARM64 architecture"
7779 else
135137echo " Installing Kosli CLI..."
136138debug_print " Starting installation process"
137139debug_print " Current PATH: $PATH "
138- set -- " /usr/local/bin" " /usr/bin" " /opt/bin"
139- while [ -n " $1 " ]; do
140- debug_print " Checking directory: $1 "
140+
141+ # Check directories one by one instead of using set --
142+ for dir in " /usr/local/bin" " /usr/bin" " /opt/bin" ; do
143+ debug_print " Checking directory: $dir "
141144 # Check if destination directory exists and is in the PATH
142- if [ -d " $1 " ] && echo " $PATH " | grep -q " $1 " ; then
143- debug_print " Directory $1 exists and is in PATH"
144- debug_print " Attempting to move $FILE_NAME to $1 "
145- if mv " $FILE_NAME " " $1 /" ; then
145+ if [ -d " $dir " ] && echo " $PATH " | grep -q " $dir " ; then
146+ debug_print " Directory $dir exists and is in PATH"
147+ debug_print " Attempting to move $FILE_NAME to $dir "
148+ if mv " $FILE_NAME " " $dir /" ; then
146149 echo " "
147- echo " ✅ Kosli CLI was successfully installed in $1 "
150+ echo " ✅ Kosli CLI was successfully installed in $dir "
148151 echo " Running 'kosli version' to verify:"
149152 debug_print " Installation successful, running version check"
150153 kosli version
151154 exit 0
152155 else
153156 echo " "
154157 echo " Attempting to install with sudo..."
155- echo " We'd like to install the Kosli CLI executable in '$1 '. Please enter your password if prompted."
158+ echo " We'd like to install the Kosli CLI executable in '$dir '. Please enter your password if prompted."
156159 debug_print " Regular move failed, trying with sudo"
157- if sudo mv " $FILE_NAME " " $1 /" ; then
160+ if sudo mv " $FILE_NAME " " $dir /" ; then
158161 echo " "
159- echo " ✅ Kosli CLI was successfully installed in $1 "
162+ echo " ✅ Kosli CLI was successfully installed in $dir "
160163 echo " Running 'kosli version' to verify:"
161164 debug_print " Sudo installation successful, running version check"
162165 kosli version
163166 exit 0
164167 fi
165- debug_print " Sudo move also failed for $1 "
168+ debug_print " Sudo move also failed for $dir "
166169 fi
167170 else
168- debug_print " Directory $1 either doesn't exist or is not in PATH"
171+ debug_print " Directory $dir either doesn't exist or is not in PATH"
169172 fi
170- shift
171173done
172174
173175debug_print " All installation attempts failed"
0 commit comments