21 lines
630 B
Bash
Executable file
21 lines
630 B
Bash
Executable file
#!/bin/sh
|
|
# this is a wget stub which directly interfaces with the browsers javascript fetch()
|
|
# REASON: way less overhead / complexity compared to the v86 linux networking stack
|
|
|
|
url="$1"
|
|
filename="$(basename "$url")"
|
|
tmp=/mnt/$$
|
|
|
|
test -z "$1" && { echo "usage: $0 <url> [-o outfile]"; exit 0; }
|
|
|
|
for arg in $*; do
|
|
test $arg = "-o" && shift && filename=$*
|
|
shift
|
|
done
|
|
|
|
js '$("[isoterminal]").emit("create_file_from_url",["'$tmp'","'$url'"])'
|
|
while sleep 0.5s; do
|
|
printf "." 1>&2
|
|
test "$(awk '{ print $1 }' $tmp)" = 0 && retcode=1 || retcode=0
|
|
test -f $tmp && mv $tmp "$filename" && printf "\n" && exit $retcode
|
|
done
|