Skip to content

Commit 69a56a5

Browse files
committed
fix compatibility error with *BSD echo, checked with: "./test.sh", "sh ./test.sh", "zsh ./test.sh", "bash ./test.sh"
1 parent af13023 commit 69a56a5

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

spinner.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function _spinner() {
3939
# calculate the column where spinner and status msg will be displayed
4040
let column=$(tput cols)-${#2}-8
4141
# display message and position the cursor in $column column
42-
echo -ne ${2}
42+
printf "${2}"
4343
printf "%${column}s"
4444

4545
# start spinner
@@ -55,23 +55,23 @@ function _spinner() {
5555
;;
5656
stop)
5757
if [[ -z ${3} ]]; then
58-
echo "spinner is not running.."
58+
printf "spinner is not running..\n"
5959
exit 1
6060
fi
6161

6262
kill $3 > /dev/null 2>&1
6363

6464
# inform the user uppon success or failure
65-
echo -en "\b["
65+
printf "\b["
6666
if [[ $2 -eq 0 ]]; then
67-
echo -en "${green}${on_success}${nc}"
67+
printf "${green}${on_success}${nc}"
6868
else
69-
echo -en "${red}${on_fail}${nc}"
69+
printf "${red}${on_fail}${nc}"
7070
fi
71-
echo -e "]"
71+
printf "]\n"
7272
;;
7373
*)
74-
echo "invalid argument, try {start/stop}"
74+
printf "invalid argument, try {start/stop}\n"
7575
exit 1
7676
;;
7777
esac

0 commit comments

Comments
 (0)