2024-08-26 12:02:35 +02:00
|
|
|
#!/bin/sh
|
2024-08-29 17:18:14 +02:00
|
|
|
test -z "$1" && { echo "Usage: js 'somefunction(1)'"; exit 0; }
|
2024-08-27 20:40:05 +02:00
|
|
|
|
2024-08-29 17:18:14 +02:00
|
|
|
test -n "$BROWSER" || { alert warning "/dev/browser not active (are you running outside of v86?)"; }
|
2024-08-27 20:40:05 +02:00
|
|
|
javascript="$*"
|
|
|
|
|
|
|
|
# if we are run as shebang, use the file as input
|
|
|
|
case "$1" in
|
2024-08-29 17:18:14 +02:00
|
|
|
*/*) javascript="args = String('$*').split(' '); $(cat $1 | tail +2)"
|
2024-08-27 20:40:05 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2024-08-29 17:18:14 +02:00
|
|
|
echo -n "$javascript" > /dev/browser/js
|
2024-08-27 20:40:05 +02:00
|
|
|
|
2024-08-29 17:18:14 +02:00
|
|
|
# should we use flock, an awesome way to make processes read/write the same file
|
|
|
|
# while preventing 1001 concurrency issues?
|
|
|
|
# attempt:
|
|
|
|
#
|
|
|
|
# flock /dev/browser/js -c "echo \"$javascript\" > /dev/browser/js"
|