What if .bash_profile doesn't exist?
We get an error from cp We still respond that we made a backup Instead if .bas_profile exists and cp is a success then prompt informing the user that we made a backup or inform them that no .bash_profile was found so no need to make a back up at this point.pull/174/head
parent
d4d3d8c9e8
commit
19fe69e566
|
|
@ -3,13 +3,17 @@
|
|||
BASH_IT=$(cd ${0%/*} && echo ${PWD})
|
||||
cd "${OLDPWD}"
|
||||
cp "${HOME}/.bash_profile" "${HOME}/.bash_profile.bak"
|
||||
|
||||
BASH_PROFILE_BAK="${HOME}/.bash_profile.bak"
|
||||
if [ -f "${BASH_PROFILE_BAK}" ]; then
|
||||
list=($(ls "${BASH_PROFILE_BAK}"*))
|
||||
BASH_PROFILE_BAK="${BASH_PROFILE_BAK}.${#list[@]}"
|
||||
fi
|
||||
|
||||
echo "Your original .bash_profile has been backed up to .bash_profile.bak"
|
||||
[[ -f "${HOME}/.bash_profile" ]] \
|
||||
&& cp "${HOME}/.bash_profile" "${BASH_PROFILE_BAK}" \
|
||||
&& echo "Your original .bash_profile has been backed up to ${BASH_PROFILE_BAK##*/}" \
|
||||
|| echo "No original .bash_profile file found so we have nothing to back up"
|
||||
|
||||
cp "${BASH_IT}/template/bash_profile.template.bash" "${HOME}/.bash_profile"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue