bopher-ng

A better Gopher client in pure Bash
git clone git://git.luxferre.top/bopher-ng.git
Log | Files | Refs | README | LICENSE

commit 7bd6a03e91291b0437b9e4dd5549ad1f977dcc1b
parent 8060459dc777d69a22fdf0a7694b1d9c03265787
Author: Luxferre <lux@ferre>
Date:   Tue,  4 Apr 2023 07:28:39 +0300

improved list2map.sh a bit

Diffstat:
Mtools/list2map.sh | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/tools/list2map.sh b/tools/list2map.sh @@ -21,6 +21,7 @@ typequery() { # external command wrapper to fetch the file's MIME type while read -rs fpath; do # fully line-based operation ftype="$(typequery "$fpath")" # MIME type here bname="${fpath##*/}" # basename here + desc="$bname" # default to the basename [[ "$bname" == "$INDEXFILE" ]] && continue # skip index map etype=9 # default map entry type is binary until proven otherwise esel="${fpath##$RDIR}" # if RDIR is empty, they are the same @@ -29,7 +30,10 @@ while read -rs fpath; do # fully line-based operation esel="${esel}/${INDEXFILE}" # update the selector elif [[ "${ftype%%/*}" == 'text' ]]; then # update etype for text files etype=0 + read -rsd$'\r' desc < "$fpath" # read the first file line as the description/title + desc="${desc##*([[:blank:]])}" # remove leading whitespace + desc="${desc%%*([[:blank:]])}" # remove trailing whitespace fi # output the RFC-compliant Gophermap line - printf '%s%s\t%s\t%s\t%s\r\n' "$etype" "$bname" "$esel" "$THOST" "$TPORT" + printf '%s%s\t%s\t%s\t%s\r\n' "$etype" "$desc" "$esel" "$THOST" "$TPORT" done