xrsh-com/com/isoterminal/mnt/js
Leon van Kammen 7bfa591536
All checks were successful
/ test (push) Successful in 4s
various unix utilities to interface with browser
2024-08-27 18:40:05 +00:00

16 lines
425 B
Bash
Executable file

#!/bin/sh
test -z $1 && { echo "Usage: js 'somefunction(1)'"; exit 0; }
javascript="$*"
# if we are run as shebang, use the file as input
case "$1" in
*/*) javascript="$(cat $1 | tail +2)"
;;
esac
flock /dev/browser/js -c "echo '$javascript' > /dev/browser/js; sleep 0.5; cat /dev/browser/js"
# we use flock, an awesome way to make processes read/write the same file
# while preventing 1001 concurrency issues