dot

packages and services management
Log | Files | Refs | README

commit ee22bcafd0cf9ebe3a5b4e3f8b957494f715d81c
parent 33bb4fc8e84e012106a4d2a90304c2f1832f2011
Author: Josuah Demangeon <mail@josuah.net>
Date:   Tue,  5 Dec 2017 10:19:14 +0100

fixed uri parsing

Diffstat:
Mbin/mblaze-filter | 2+-
Mbin/uri | 16++++++++--------
Dbin/www | 56--------------------------------------------------------
Mbin/xdg-open | 21++++++++++++---------
Mconfig/git/config | 5+++--
5 files changed, 24 insertions(+), 76 deletions(-)

diff --git a/bin/mblaze-filter b/bin/mblaze-filter @@ -9,7 +9,7 @@ do mkdir -p "${MAIL%/*}/$dir/new" mkdir -p "${MAIL%/*}/$dir/tmp" printf '%-25s ' "$dir" - mlist "$MAIL" | mpick -t "$test" | xargs -rI {} mv {} "$MAIL/../dir/new" + mlist "$MAIL" | mpick -t "$test" | xargs -rI {} mv {} "$MAIL/../$dir/new" done << 'EOF' actux.eu.org "Reply-To" ~~~ "*@actux.eu.org*" amazon.com "From" ~~~ "*@amazon.*" diff --git a/bin/uri b/bin/uri @@ -5,13 +5,13 @@ $(printf %s "$1" | awk '{ gsub("\t", "%0b"); scheme = $0; - if (sub("[^:/]*://", "", $0) > 0) + if (sub("^[^:/]*://", "", $0) > 0) sub("://.*", "", scheme); else scheme = "."; user = $0; - if (sub("[^@/]*@", "", $0) > 0) + if (sub("^[^@/]*@", "", $0) > 0) sub("@.*", "", user); else user = "."; @@ -22,19 +22,19 @@ $(printf %s "$1" | awk '{ else pass = "."; - printf("\n\t[ %s ]\n\n", $0) > "/dev/stderr"; - host = $0 - if (sub("[^:]*:", "", $0) > 0) + if (sub("^[^:]*:", ":", $0) > 0) sub(":.*", "", host); else if (sub("[^/]*/", "/", $0) > 0) sub("/.*", "", host); port = $0 - if (sub(":[0-9]+", "", $0) > 0) - sub("[^:]*:", "", port); - else + if (sub("^:[0-9]+:", "", $0) > 0 || sub("^:[0-9]+/", "/", $0) > 0) { + sub(":", "", port); + sub("[:/].*", "", port); + } else { port = "."; + } path = $0; diff --git a/bin/www b/bin/www @@ -1,56 +0,0 @@ -#!/bin/sh -# fast static website generator using POSIX sh, printf, find, and sed - -LAYOUT=$(sed '' layout.html) || exit 1 - -#1 directory processed -#2 content of the layout to parse - -parse() -{ - printf %s "${2%%{{*}" - - [ "${2##*{{*}" ] && return 0 - - set -- "$1" "${2#*{{}" - - case "${2%%\}\}*}" in - (*content*) [ -f "$1/index" ] && sed "$1/index" ;; - (*title* ) printf %s "${1##*/}" ;; - (*root* ) root "$1" ;; - (*nav* ) nav "$1" ;; - (*list* ) list "$1" ;; - esac - - parse "$1" "${2#*\}\}}" -} - -root() -{ - printf %s/ "$1" | sed 's|[^/]||g; s|.|../|g; s|/$||; s|^$|.|' -} - -nav() -{ - find -L . -mindepth 1 -maxdepth 1 -type d ! -name '.*' | sort | - sed 's|..||' | while IFS='' read -r path - do printf ' <a href="%s">%s</a>' "$(root "$1")/$path" "$path" - done -} - -list() -{ - [ "$1" != . ] && find -L "$1" -mindepth 1 -maxdepth 1 ! -name 'index*' | - sort | sed 's|.*/||' | while IFS='' read -r path - do - printf -- '<li><a href="%s">%s%s</a></li>\n' "$path" "$path" "$( - [ -f "$path/index" ] && sed 's|^| - | q' "$path/index" - )" - done -} - -for dir in "$@" -do parse "$dir" "$LAYOUT" > "$dir/index.html" -done - -parse . "$LAYOUT" > index.html diff --git a/bin/xdg-open b/bin/xdg-open @@ -15,20 +15,20 @@ printf '\033]0;%s\a' "$name" tty | grep -q -e '^/dev/pts/.*' -e '^/dev/tty*' || exec st -f terminus:pixelsize=18 -e "$0" "$@" -# scheme://[user[:pass]@]host[:port][[:][/]path][/path] -IFS=' ' read scheme user pass host port path << EOF +# scheme://[user[:pass]@]host[:port][/path] +IFS=' ' read scheme user pass host port path << EOF $(printf %s "$1" | awk '{ gsub(" ", "%20"); gsub("\t", "%0b"); scheme = $0; - if (sub("[^:/]*://", "", $0) > 0) + if (sub("^[^:/]*://", "", $0) > 0) sub("://.*", "", scheme); else scheme = "."; user = $0; - if (sub("[^@/]*@", "", $0) > 0) + if (sub("^[^@/]*@", "", $0) > 0) sub("@.*", "", user); else user = "."; @@ -40,16 +40,18 @@ $(printf %s "$1" | awk '{ pass = "."; host = $0 - if (sub("[^:]*:", "", $0) > 0) + if (sub("^[^:]*:", ":", $0) > 0) sub(":.*", "", host); else if (sub("[^/]*/", "/", $0) > 0) sub("/.*", "", host); port = $0 - if (sub(":[0-9]+", "", $0) > 0) - sub("[^:]*:", "", port); - else + if (sub("^:[0-9]+:", "", $0) > 0 || sub("^:[0-9]+/", "/", $0) > 0) { + sub(":", "", port); + sub("[:/].*", "", port); + } else { port = "."; + } path = $0; @@ -96,7 +98,8 @@ case $scheme in aexec doas 9pfs "$address" "$dir" ;; (git) - cd "$HOME/src" || exit 1 + mkdir -p "$HOME/git" + cd "$HOME/git" || exit 1 aexec git clone "$1" ;; (telnet) diff --git a/config/git/config b/config/git/config @@ -3,8 +3,9 @@ name = Josuah Demangeon [alias] - graph = log --graph --date=short --decorate --tags --branches \ - --remotes --stat + dog = log --graph --date=short --decorate --tags --branches \ + --remotes --format='%h %ad %s' + stat = log --graph --decorate --tags --branches --remotes --stat poule = pull [core]