File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,6 +37,24 @@ feedback() {
3737 echo -e " $( tput setaf 3) $1 $( tput sgr0) "
3838}
3939
40+ # Function checks out branch if BRANCH is defined.
41+ change_branch () {
42+ # first and only parameter is the branch to checkout
43+
44+ # -z tests for zero length.
45+ if [ -z ${1+x} ]; then
46+ echo " Working from main branch." ;
47+ else
48+ echo " Working from $1 branch" ;
49+ # sudo git checkout -b $BRANCH
50+ # the -b creates a branch if it doesn't exist
51+ # this leads to a fatal error msg being displayed to the user
52+ # is there any case where we can to create the branch here???
53+ # https://github.com/tldr-pages/tldr/blob/master/pages/common/git-checkout.md
54+ sudo git checkout $1
55+ fi
56+ }
57+
4058# ########################################################################
4159#
4260# FILE EDITION
@@ -135,9 +153,9 @@ file_exists_in_folder(){
135153 # can only be run using bash, not sh
136154 # first argument: file to look for
137155 # second argument: folder path
138- pushd $2
139- status = file_exists
140- popd
156+ pushd $2 > /dev/null
157+ status = file_exists $1
158+ popd > /dev/null
141159 return status
142160}
143161
You can’t perform that action at this time.
0 commit comments