@@ -203,24 +203,22 @@ brew doctor
203203# Add GNU utilities to PATH once in .shellpaths
204204shellpaths_file=" ./homedir/.shellpaths"
205205
206- # Determine Homebrew prefix once using brew if available
207- if command -v brew > /dev/null 2>&1 ; then
208- brew_prefix=" $( brew --prefix) "
209- elif grep -qs " /opt/homebrew/bin" " $shellpaths_file " ; then
210- brew_prefix=" /opt/homebrew"
211- elif grep -qs " /usr/local/bin" " $shellpaths_file " ; then
212- brew_prefix=" /usr/local"
213- else
214- brew_prefix=" "
215- fi
206+ # Determine Homebrew prefix once using brew
207+ brew_prefix=" $( brew --prefix) "
216208
217- if [ -n " $brew_prefix " ]; then
218- for util in coreutils gnu-sed grep; do
219- path=" $brew_prefix /opt/$util /libexec/gnubin"
220- if ! grep -qs " $path " " $shellpaths_file " ; then
221- echo " export PATH=\" $path :\$ PATH\" " >> " $shellpaths_file "
222- fi
223- done
209+ # Append gnubin directories for GNU utilities if missing
210+ coreutils_path=" $brew_prefix /opt/coreutils/libexec/gnubin"
211+ sed_path=" $brew_prefix /opt/gnu-sed/libexec/gnubin"
212+ grep_path=" $brew_prefix /opt/grep/libexec/gnubin"
213+
214+ if ! grep -qs " $coreutils_path " " $shellpaths_file " ; then
215+ echo " export PATH=\" $coreutils_path :\$ PATH\" " >> " $shellpaths_file "
216+ fi
217+ if ! grep -qs " $sed_path " " $shellpaths_file " ; then
218+ echo " export PATH=\" $sed_path :\$ PATH\" " >> " $shellpaths_file "
219+ fi
220+ if ! grep -qs " $grep_path " " $shellpaths_file " ; then
221+ echo " export PATH=\" $grep_path :\$ PATH\" " >> " $shellpaths_file "
224222fi
225223
226224# skip those GUI clients, git command-line all the way
0 commit comments