WebAssembly / WebAssembly/WASI
Converting a little Bash script to WAT as an exercise
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.8k
- Forks
- 333
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
People,
I want to convert the little Bash script hereunder to WAT as an actuall useful exercise for me to getting started with WASM - the script simply counts the number of emails in a Maildir tree that are less than x minutes old and prints the numbers out for each of the dirs.
I presume I will need WASI for this exercise - pointers to any similar exercises would be helpful . .
Thanks,
Phil.
#!/bin/sh
# $1 host
# $2 minutes
# $3 x - extra flag to do all dirs
function proc_dir()
{
if [ "$3" == "count" ]; then # Show counts of mails of all dirs within minutes
count=`find $1 -name "1*," -mmin -$2 | wc -l`
if [ "$count" != "0" ]; then
echo -n "$1: " | sed 's/^.*Maildir\/\.//'
echo $count
else
continue
fi
else # Shows Subjects of main dirs
emails=`find $1/new $1/cur -name "1*," -mmin -$2 | sort -r`
if [ "$emails" != "" ]; then
for email in $emails
do
base=`echo $dir | sed 's/^.*\/\.//'`
echo -n "${base}: "
grep "^Subject: " $email | head -1 | sed 's/^Subject: //' | decode_utf8.pl
done
fi
fi
}
if [ $1 == "localhost" ]; then
maildir=$HOME/Maildir
else
sshfs $1:/home/phr/Maildir /home/phr/md
maildir=$HOME/md
fi
# echo $maildir
maindirs="
0_caa
0_caa_list
0_cryo
0_cryo_ssa-sc
0_naf
1_qps
1_qps_3-5_saje_crt"
if (( $# > 2 )); then # Do counts
# dirs=`cd $maildir ; find . -exec basename {} \; -regextype grep -regex "^\.[0-9a-z][^.]+$ | sort"
dirs=`cd $maildir ; ls -1a | grep -E "^\.[0-9a-z][^.]+$"`
for dir in $dirs
do
proc_dir $maildir/$dir $2 count
done
else # Get maindirs Subjects
proc_dir $maildir $2
for dir in $maindirs
do
proc_dir $maildir/.$dir $2
done
fi
sleep 5
if [ $1 != "localhost" ]; then
fusermount -u /home/phr/md
fi
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue names only a Bash script and a desired WAT/WASI exercise; no repository file, test, or entry point is identified. First clarify whether the intended outcome is a code example, documentation, or general guidance, then define acceptance criteria for the Maildir traversal and output before implementation can begin.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, wasm
- Domain
- cli, operating-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100