Skip to content

Instantly share code, notes, and snippets.

@iandelahorne
Created November 1, 2013 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iandelahorne/7264014 to your computer and use it in GitHub Desktop.
Save iandelahorne/7264014 to your computer and use it in GitHub Desktop.
/etc/profile.d/sbin.sh
path_elems=(${PATH//:/ })
sbin_missing=1
usr_sbin_missing=1
usr_local_sbin_missing=1
for i in "${!path_elems[@]}" ; do
if [ "${path_elems[i]}" = /sbin ]; then sbin_missing = 0 ; fi
if [ "${path_elems[i]}" = /usr/sbin ]; then usr_sbin_missing = 0 ; fi
if [ "${path_elems[i]}" = /usr/local/sbin ]; then usr_local_sbin_missing = 0 ; fi
done
if [ $sbin_missing -gt 0 ] ; then
PATH=/sbin:$PATH
fi
if [ $usr_sbin_missing -gt 0 ] ; then
PATH=/usr/sbin:$PATH
fi
if [ $usr_local_sbin_missing -gt 0 ] ; then
PATH=/usr/local/sbin:$PATH
fi
unset path_elems
unset sbin_missing
unset usr_sbin_missing
unset usr_local_sbin_missing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment