1
1
# Constants
2
- PGLET_VER=" 0.1.12 " # Pglet version required by this script
2
+ PGLET_VER=" 0.2.0 " # Pglet version required by this script
3
3
4
4
# Default session variables:
5
5
PGLET_EXE=" " # full path to Pglet executable
@@ -40,6 +40,10 @@ function pglet_page() {
40
40
pargs+=(--no-window)
41
41
fi
42
42
43
+ if [[ " $PGLET_TICKER " != " " ]]; then
44
+ pargs+=(--ticker $PGLET_TICKER )
45
+ fi
46
+
43
47
# execute pglet and get page connection ID
44
48
local page_results=` $PGLET_EXE " ${pargs[@]} " `
45
49
IFS=' ' read -r PGLET_CONNECTION_ID PGLET_PAGE_URL <<< " $page_results"
@@ -86,6 +90,10 @@ function pglet_app() {
86
90
pargs+=(--no-window)
87
91
fi
88
92
93
+ if [[ " $PGLET_TICKER " != " " ]]; then
94
+ pargs+=(--ticker $PGLET_TICKER )
95
+ fi
96
+
89
97
# reset vars
90
98
PGLET_PAGE_URL=" "
91
99
@@ -120,7 +128,7 @@ function pglet_send() {
120
128
echo " $cmd " > " $conn_id "
121
129
122
130
# take result if command doesn't end with "f" (fire-and-forget)
123
- if [[ " $cmd " =~ ^[[:space:]] * [A-Za-z]+ f ]]; then
131
+ if [[ " $cmd " =~ \s * \w * f ]]; then
124
132
return
125
133
fi
126
134
@@ -202,7 +210,7 @@ function pglet_wait_event() {
202
210
local conn_id=$PGLET_CONNECTION_ID
203
211
fi
204
212
205
- IFS= ' ' read PGLET_EVENT_TARGET PGLET_EVENT_NAME PGLET_EVENT_DATA < " $conn_id .events"
213
+ read PGLET_EVENT_TARGET PGLET_EVENT_NAME PGLET_EVENT_DATA < " $conn_id .events"
206
214
}
207
215
208
216
function pglet_dispatch_events() {
@@ -228,19 +236,32 @@ function pglet_dispatch_events() {
228
236
}
229
237
230
238
function __pglet_install() {
231
- if [ " $( uname -m) " != " x86_64" ]; then
232
- echo " Error: Unsupported architecture $( uname -m) . Only x64 binaries are available." 1>&2
233
- exit 1
234
- fi
235
239
236
240
if [ " $OS " = " Windows_NT" ]; then
237
241
echo " Error: Bash for Windows is not supported." 1>&2
238
242
exit 1
243
+ fi
244
+
245
+ platform=$( uname -s)
246
+ if [[ $platform == Darwin ]]; then
247
+ platform=" darwin"
248
+ elif [[ $platform == Linux ]]; then
249
+ platform=" linux"
250
+ else
251
+ echo " Error: Unsupported platform $platform ." 1>&2
252
+ exit 1
253
+ fi
254
+
255
+ arch=$( uname -m)
256
+ if [[ $arch == x86_64 ]] || [[ $arch == amd64 ]]; then
257
+ arch=" amd64"
258
+ elif [[ $arch == arm64 ]] || [[ $arch == aarch64 ]]; then
259
+ arch=" arm64"
260
+ elif [[ $arch == arm ]] || [[ $arch == armv7l ]]; then
261
+ arch=" arm"
239
262
else
240
- case $( uname -s) in
241
- Darwin) target=" darwin-amd64.tar.gz" ;;
242
- * ) target=" linux-amd64.tar.gz" ;;
243
- esac
263
+ echo " Error: Unsupported architecture $arch ." 1>&2
264
+ exit 1
244
265
fi
245
266
246
267
# check if pglet.exe is in PATH already (development mode)
@@ -271,13 +292,11 @@ function __pglet_install() {
271
292
mkdir -p " $pglet_bin "
272
293
fi
273
294
274
- local pglet_url=" https://github.com/pglet/pglet/releases/download/v${ver} /pglet-${target} "
295
+ local pglet_url=" https://github.com/pglet/pglet/releases/download/v${ver} /pglet-${ver} - ${platform} - ${arch} .tar.gz "
275
296
local tempTar=" $HOME /.pglet/pglet.tar.gz"
276
297
curl -fsSL $pglet_url -o $tempTar
277
298
tar zxf $tempTar -C $pglet_bin
278
299
rm $tempTar
279
-
280
- # echo "OK"
281
300
fi
282
301
}
283
302
0 commit comments