From 7efd021112f91f8a843b6695ca984e50039ea954 2021-11-26 22:49:15 From: Matthias Bussonnier Date: 2021-11-26 22:49:15 Subject: [PATCH] release script zsh compatibility --- diff --git a/tools/release_helper.sh b/tools/release_helper.sh index 4d5672b..a1aa263 100644 --- a/tools/release_helper.sh +++ b/tools/release_helper.sh @@ -21,7 +21,7 @@ WHITE=$(tput setaf 7) NOR=$(tput sgr0) -echo "Will use $EDITOR to edit files when necessary" +echo "Will use $BLUE'$EDITOR'$NOR to edit files when necessary" echo -n "PREV_RELEASE (X.y.z) [$PREV_RELEASE]: " read input PREV_RELEASE=${input:-$PREV_RELEASE} @@ -37,11 +37,15 @@ BRANCH=${input:-$BRANCH} ask_section(){ echo - echo $BLUE"$1"$NOR + echo $BLUE"$1"$NOR echo -n $GREEN"Press Enter to continue, S to skip: "$NOR - read -n1 value - echo - if [ -z $value ] || [ $value = 'y' ] ; then + if [ "$ZSH_NAME" = "zsh" ] ; then + read -k1 value + value=${value%$'\n'} + else + read -n1 value + fi + if [ -z "$value" ] || [ $value = 'y' ]; then return 0 fi return 1 @@ -51,11 +55,17 @@ ask_section(){ maybe_edit(){ echo echo $BLUE"$1"$NOR - echo -n $GREEN"Press e to Edit $1, any other keys to skip: "$NOR - read -n1 value + echo -n $GREEN"Press ${BLUE}e$GREEN to Edit ${BLUE}$1$GREEN, any other keys to skip: "$NOR + if [ "$ZSH_NAME" = "zsh" ] ; then + read -k1 value + value=${value%$'\n'} + else + read -n1 value + fi + echo if [ $value = 'e' ] ; then - $EDITOR $1 + $=EDITOR $1 fi } @@ -100,7 +110,7 @@ then git checkout $PREV_RELEASE echo $BLUE"Saving API to file $PREV_RELEASE"$NOR frappuccino IPython --save IPython-$PREV_RELEASE.json - echo $BLUE"coming back to $BRANCH"$NOR + echo $BLUE"comming back to $BRANCH"$NOR git checkout $BRANCH echo $BLUE"comparing ..."$NOR frappuccino IPython --compare IPython-$PREV_RELEASE.json @@ -116,7 +126,7 @@ echo $GREEN"please update version number in ${RED}IPython/core/release.py${NOR} echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py${NOR}" sed -i bkp -e '/Uncomment/s/^# //g' IPython/core/release.py rm IPython/core/release.pybkp -git diff +git diff | cat maybe_edit IPython/core/release.py echo $GREEN"Press enter to continue"$NOR @@ -163,7 +173,7 @@ then echo $GREEN"I tried ${RED}sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py${NOR}" sed -i bkp -e '/Uncomment/s/^/# /g' IPython/core/release.py rm IPython/core/release.pybkp - git diff + git diff | cat echo $GREEN"Please bump ${RED}the minor version number${NOR}" maybe_edit IPython/core/release.py echo ${BLUE}"Do not commit yet – we'll do it later."$NOR