Add mblaze related files
This commit is contained in:
parent
96862e6556
commit
69e00b6f58
6 changed files with 398 additions and 0 deletions
117
mblaze/m.sh
Normal file
117
mblaze/m.sh
Normal file
|
@ -0,0 +1,117 @@
|
|||
#!/bin/sh
|
||||
# mblaze.env
|
||||
# Written in 2020 by Lucas
|
||||
# CC0 1.0 Universal/Public domain - No rights reserved
|
||||
#
|
||||
# To the extent possible under law, the author(s) have dedicated all
|
||||
# copyright and related and neighboring rights to this software to the
|
||||
# public domain worldwide. This software is distributed without any
|
||||
# warranty. You should have received a copy of the CC0 Public Domain
|
||||
# Dedication along with this software. If not, see
|
||||
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat - <<. >&2
|
||||
Usage:
|
||||
${0##*/} f|fetch
|
||||
${0##*/} l|list [dirs...]
|
||||
${0##*/} r|read dir [dirs...]
|
||||
${0##*/} s|scan [-a] dir [dirs...]
|
||||
.
|
||||
exit 1
|
||||
}
|
||||
|
||||
_mdirs()
|
||||
{
|
||||
mdirs "$@" | sort -t /
|
||||
}
|
||||
|
||||
m_fetch_usage()
|
||||
{
|
||||
printf "Usage: %s f|fetch\n" "${0##*/}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
m_read_usage()
|
||||
{
|
||||
printf "Usage: %s r|read dir [dirs...]\n" "${0##*/}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
m_scan_usage()
|
||||
{
|
||||
printf "Usage: %s s|scan [-a] dir [dirs...]\n" "${0##*/}" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
m_fetch()
|
||||
{
|
||||
if [ $# -ne 0 ]; then
|
||||
m_fetch_usage
|
||||
fi
|
||||
printf "%s: fetch TBD.\n" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
m_list()
|
||||
{
|
||||
pwd=$(pwd)
|
||||
# cut(1) lists are 1-based, and +1 for leading slash
|
||||
_mdirs "${@:-.}" | cut -c $((${#pwd} + 2))- | mlist -i
|
||||
}
|
||||
|
||||
m_read()
|
||||
{
|
||||
if [ $# -eq 0 ]; then
|
||||
m_read_usage
|
||||
fi
|
||||
|
||||
_mdirs "$@" | mlist -s | msort -d | mthread | mless
|
||||
}
|
||||
|
||||
m_scan()
|
||||
{
|
||||
mlist_flags=-s
|
||||
while getopts a flag; do
|
||||
case $flag in
|
||||
a)
|
||||
mlist_flags=
|
||||
;;
|
||||
*)
|
||||
m_scan_usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
m_scan_usage
|
||||
fi
|
||||
|
||||
_mdirs "$@" | mlist $mlist_flags | msort -d | mthread | mseq -S | mscan
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ]; then
|
||||
usage
|
||||
fi
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
case $cmd in
|
||||
f|fetch)
|
||||
m_fetch "$@"
|
||||
;;
|
||||
l|list)
|
||||
m_list "$@"
|
||||
;;
|
||||
r|read)
|
||||
m_read "$@"
|
||||
;;
|
||||
s|scan)
|
||||
m_scan "$@"
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
Loading…
Add table
Add a link
Reference in a new issue