@@ -48,28 +48,62 @@ catch() {
48
48
fi
49
49
}
50
50
51
+ # spinner() {
52
+ # pid=$1
53
+ # spin='-\|/'
54
+ # i=0
55
+
56
+ # while kill -0 $pid 2>/dev/null; do
57
+ # i=$(((i + 1) % 4))
58
+
59
+ # # If we are in a github actions workflow, we don't want to print the spinner
60
+ # if [ "$GITHUB_ACTIONS" != "true" ]; then
61
+ # printf "\r${spin:$i:1}"
62
+ # fi
63
+
64
+ # sleep .1
65
+ # done
66
+
67
+ # # If we are in a github actions workflow, we don't want to print this return line
68
+ # if [ "$GITHUB_ACTIONS" != "true" ]; then
69
+ # printf "\r"
70
+ # fi
71
+ # }
72
+
51
73
spinner () {
52
- pid= $1
74
+ arg= " $1 "
53
75
spin=' -\|/'
54
76
i=0
55
77
56
- while kill -0 $pid 2> /dev/null; do
57
- i=$(( (i + 1 ) % 4 ))
78
+ check_condition () {
79
+ if [[ " $arg " =~ ^[0-9]+$ ]]; then
80
+ # Numeric: assume it's a PID
81
+ ! kill -0 " $arg " 2> /dev/null
82
+ elif [[ " $arg " == /* ]]; then
83
+ # Starts with /: assume it's a file path
84
+ [ -e " $arg " ]
85
+ else
86
+ # Otherwise: check if command is in PATH
87
+ command -v " $arg " > /dev/null 2>&1
88
+ fi
89
+ }
58
90
59
- # If we are in a github actions workflow, we don't want to print the spinner
91
+ while ! check_condition; do
92
+ i=$(( (i + 1 ) % 4 ))
93
+ # If we are in a GitHub Actions workflow, we don't want to print the spinner
60
94
if [ " $GITHUB_ACTIONS " != " true" ]; then
61
95
printf " \r${spin: $i : 1} "
62
96
fi
63
-
64
97
sleep .1
65
98
done
66
99
67
- # If we are in a github actions workflow, we don't want to print this return line
100
+ # If we are in a GitHub Actions workflow, we don't want to print this return line
68
101
if [ " $GITHUB_ACTIONS " != " true" ]; then
69
102
printf " \r"
70
103
fi
71
104
}
72
105
106
+
73
107
# ################
74
108
# ## FUNCTIONS ###
75
109
# ################
@@ -273,7 +307,7 @@ install_froster() {
273
307
echo " Installing from the current directory"
274
308
echo -e " \nInstalling Froster from the current directory in --editable mode..."
275
309
python3 -m pip install --force -e . > /dev/null 2>&1 & # >/dev/null 2>&1
276
- spinner $!
310
+ spinner " froster "
277
311
sleep 3
278
312
if ! [[ -f " ${HOME} /.local/bin/froster" ]]; then
279
313
echo " ${HOME} /.local/bin/froster not available, exiting."
0 commit comments