better curl/wget

This commit is contained in:
Leon van Kammen 2025-06-24 12:49:55 +02:00
parent e6595dc6b1
commit 30b8404f3e
10 changed files with 43 additions and 16 deletions

View file

@ -37,6 +37,7 @@ help_tips(){
echo 'programming languages ' "type 'ls ~/bin/helloworld*'"
echo 'upload file to xrsh ' "type 'upload <file>'"
echo 'download file locally ' "type 'download <file>'"
echo 'download remote file ' "type 'wget https://nlnet.nl/index.html -o index.html'"
echo 'paste text ' "ctrl/cmd+shift+v'"
echo 'paste text to file ' "ctrl/cmd+v'"
echo 'import file to scene ' "drag-drop file or ctrl/cmd+v or type 'upload'"

View file

@ -4,7 +4,6 @@ alias mg='echo -e "HINT: type Ctrl+c Ctrl-x to quit\n[press a key]";read;mg';
alias nano='echo -e "HINT: type Ctrl+x to quit\n[press a key]" ;read;nano';
# save space in the iso image
alias curl="wget -q -O - "
alias make="mim"
# minimalist autoenv version [https://github.com/hyperupcall/autoenv]

View file

@ -0,0 +1,10 @@
#!/bin/sh
# this is a curl stub which directly interfaces with the browsers javascript fetch() via wget
# REASON: way less overhead / complexity compared to the v86 linux networking stack
tmp=/tmp/$$
wget "$1" -o $tmp
test -f $tmp && {
cat $tmp
rm $tmp
}

View file

@ -0,0 +1,4 @@
#!/bin/sh
test -z "$1" && { echo "usage: pkg <ls|install> [pkgname]"; exit 0; }

View file

@ -0,0 +1,21 @@
#!/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

View file

@ -1,2 +0,0 @@
#!/bin/sh

View file

@ -3,6 +3,12 @@ set -e # halt on error
file="$1"
dir="$(basename "$file")"
echo "$file" | grep -q http && {
filename="$(basename "$file")"
wget "$file" -o /tmp/$$.zip
file=/tmp/$$.zip
}
logger "$0: extracting $file"
test -d "/root/$dir" && rm -rf "/root/$dir"

View file

@ -1,13 +0,0 @@
#!/bin/html
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane position="0 0.05 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<!--
<a-box position="0 1.4 -0.5" scale="0.2 0.2 0.2" color="#FF00AA" grabbable></a-box>
-->
<!-- for [lowerlevel] THREE.js code see ~/index.js -->

View file

@ -236,6 +236,7 @@ term.emit("send", ["some input", 6])
// file operations (uses /mnt)
$('[isoterminal]').emit("create_file", ["hello.txt","hi"])
$('[isoterminal]').emit("create_file_from_url", ["index.html","https://nlnet.nl/index.html"])
$('[isoterminal]').emit("update_file", ["hello.txt","hello"])
$('[isoterminal]').emit("append_file", ["hello.txt","world"])
$('[isoterminal]').emit("read_file", ["hello.txt", console.log ])

BIN
dist/v86-linux.iso vendored

Binary file not shown.