mirror of
https://git.sr.ht/~crc_/retroforth
synced 2024-11-16 19:48:56 +01:00
a09d8cc11f
FossilOrigin-Name: 9c0fd687f43f1d2edd07514cc699ff46fe5b2d807f5886d0f8702deed67e9209
46 lines
1,001 B
Text
Executable file
46 lines
1,001 B
Text
Executable file
#!/usr/bin/env retro
|
|
|
|
This is a small tool I wrote to let me quickly share code on IRC
|
|
or via other channels.
|
|
|
|
First, get the MD5 of the source. Start by construting a pipe:
|
|
|
|
~~~
|
|
#0 sys:argv 'md5_%s s:format file:R unix:popen 'FID const
|
|
~~~
|
|
|
|
Then read in until past the prolog (MD5 filename = ...):
|
|
|
|
~~~
|
|
[ FID file:read $= eq? ] until FID file:read drop
|
|
~~~
|
|
|
|
And then read in the sum and close the pipe. The sum in kept
|
|
in a string constant MD5.
|
|
|
|
~~~
|
|
#1000 [ FID file:read , ] here × dip s:chop 'MD5 s:const
|
|
FID unix:pclose
|
|
~~~
|
|
|
|
Next, I construct string constants for the destination file
|
|
and URL's for Gopher and HTTPS.
|
|
|
|
~~~
|
|
MD5 '/home/crc/public/share/%s s:format 'DEST s:const
|
|
MD5 'http://forth.works/share/%s s:format 'HTTP s:const
|
|
MD5 'gopher://forth.works/0/share/%s s:format 'GOPH s:const
|
|
~~~
|
|
|
|
Then copy the source file to the destination directory.
|
|
|
|
~~~
|
|
here #0 sys:argv file:slurp here DEST file:spew
|
|
~~~
|
|
|
|
And finally display the URL's.
|
|
|
|
~~~
|
|
HTTP s:put nl
|
|
GOPH s:put nl
|
|
~~~
|