чување 6032b8dda141508002ade67021c828e3af7ace56
родитељ 844f51097e501676f3b647e34a3a67a100f4b581
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Tue, 12 Sep 2023 15:32:37 +0200
OpenBSD support
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 6, додавања: 40(+), брисања: 22(-)
diff --git a/.gitignore b/.gitignore
@@ -18,6 +18,7 @@ nohup.out
config.redo
ste
*.1
+*.1.html
ste.session
compile_commands.json
date
diff --git a/ste.in b/ste.in
@@ -161,8 +161,7 @@ redraw=1
sgi=$(printf "%b" "\033[")
while [ "$continue" -eq 1 ]; do
- maxrows=$(wc -l "$file" | cut -d' ' -f1)
-
+ maxrows=$(wc -l "$file" | awk '{print $1}')
_cols="$cols"
if [ "$cols" -eq 0 ]; then
_cols=$(detectcols)
diff --git a/tsvdel b/tsvdel
@@ -5,6 +5,8 @@
# any later version. Copyright (C) 2023 Страхиња Радић.
# See the file LICENSE for exact copyright and license details.
+tab=$(printf "\t")
+
usage()
{
cat <<EOT
@@ -39,11 +41,11 @@ cp "${inputfile}" "$tmpf"
trap "rm -f \"$tmpf\"" HUP PIPE INT QUIT TERM EXIT
if [ -z "${lineno}" ]; then
- lineno=$(cut -d"$(printf '\t')" -f"${colno}" "${inputfile}" \
- | grep -ni "${searchtext}" \
- | sed 's/^\([0-9]\+\).*/\1/;1q')
- [ -z "$lineno" ] \
- && { error "not found \`${searchtext}' in column ${colno}"
+ lineno=$(cut -d"$tab" -f"${colno}" "${inputfile}" |
+ grep -ni "${searchtext}" |
+ sed 's/^\([0-9]\+\).*/\1/;1q')
+ [ -z "$lineno" ] &&
+ { error "not found \`${searchtext}' in column ${colno}"
exit 1; }
fi
diff --git a/tsvedit b/tsvedit
@@ -7,6 +7,10 @@
# Needs vipe from moreutils and $EDITOR https://joeyh.name/code/moreutils/
+tab=$(printf "\t")
+nl='
+'
+
usage()
{
cat <<EOT
@@ -42,7 +46,7 @@ cp "${inputfile}" "$tmpf"
trap "rm -f \"$tmpf\"" HUP PIPE INT QUIT TERM EXIT
if [ -z "${lineno}" ]; then
- lineno=$(cut -d"$(printf '\t')" -f"${colno}" "${inputfile}" \
+ lineno=$(cut -d"$tab" -f"${colno}" "${inputfile}" \
| grep -ni "${searchtext}" \
| sed 's/^\([0-9]\+\).*/\1/;1q')
[ -z "$lineno" ] \
@@ -56,12 +60,13 @@ if [ "${lineno}" -lt 1 ]; then
fi
{ head -n$((lineno-1)) "${inputfile}"
- { sed 1q "${inputfile}" | sed -e 's/^/# /' -e 's/\t/\t# /g'
+ # shellcheck disable=SC1003
+ { sed 1q "${inputfile}" | sed -e 's/^/# /' -e 's/'"$tab"'/'"$tab"'# /g'
head -n"$lineno" "${inputfile}" | tail -n1; } |
- transpose - | sed 's/\t/\n/g' |
+ transpose - | sed 's/'"$tab"'/\'"$nl"'/g' |
vipe --suffix tsv |
- sed '/^#/d;s/\([^\t]*\)$/\1\t/g' | tr -d '\n' |
- sed 's/\t$/\n/g'
+ sed '/^#/d;s/\([^'"$tab"']*\)$/\1'"$tab"'/g' | tr -d '\n' |
+ sed 's/'"$tab"'$/\'"$nl"'/g'
tail +$((lineno+1)) "${inputfile}"; } > "$tmpf"
if diff "$tmpf" "${inputfile}" >/dev/null 2>&1; then
diff --git a/tsvins b/tsvins
@@ -7,6 +7,10 @@
# Needs vipe from moreutils and $EDITOR https://joeyh.name/code/moreutils/
+tab=$(printf "\t")
+nl='
+'
+
usage()
{
cat <<EOT
@@ -46,16 +50,21 @@ if [ $# -eq 2 ]; then
head -n"${lineno}" -- "${inputfile}" > "$tmpf"
fi
if [ "${numlines}" -gt 0 ]; then
- { sed 1q -- "${inputfile}" | sed -e 's/^/# /' -e 's/\t/\t# /g'
- sed 1q -- "${inputfile}" | sed -e 's/[^\t]*\(\t\?\)/\1/g'; } |
- transpose - | sed -e 's/\t/\n/g' |
+ # shellcheck disable=SC1003
+ { sed 1q "${inputfile}" | sed -e 's/^/# /' -e 's/'"$tab"'/'"$tab"'# /g'
+ # shellcheck disable=SC1003
+ sed 1q "${inputfile}" |
+ sed -e 's/[^'"$tab"']*\('"$tab"'\?\)/\1/g'; } |
+ transpose - | sed -e 's/'"$tab"'/\'"$nl"'/g' |
vipe --suffix tsv |
- sed '/^#/d;s/\([^\t]*\)$/\1\t/g' | tr -d '\n' |
- sed 's/\t$/\n/g' >> "$tmpf"
+ sed '/^#/d;s/\([^'"$tab"']*\)$/\1'"$tab"'/g' |
+ tr -d '\n' |
+ sed 's/'"$tab"'$/\'"$nl"'/g' >> "$tmpf"
else
+ # shellcheck disable=SC1003
vipe --suffix tsv </dev/null |
- sed 's/\([^\t]*\)$/\1\t/g' | tr -d '\n' |
- sed 's/\t$/\n/g' >> "$tmpf"
+ sed 's/\([^'"$tab"']*\)$/\1'"$tab"'/g' | tr -d '\n' |
+ sed 's/'"$tab"'$/\'"$nl"'/g' >> "$tmpf"
fi
if [ $# -eq 2 ]; then
tail +$((lineno + 1)) -- "${inputfile}" >> "$tmpf"
diff --git a/tsvmove b/tsvmove
@@ -5,6 +5,8 @@
# any later version. Copyright (C) 2023 Страхиња Радић.
# See the file LICENSE for exact copyright and license details.
+tab=$(printf "\t")
+
usage()
{
cat <<EOT
@@ -41,12 +43,12 @@ cp "${inputfile}" "$tmpf"
trap "rm -f \"$tmpf\"" HUP PIPE INT QUIT TERM EXIT
if [ -z "${linenofrom}" ]; then
- linenofrom=$(cut -d"$(printf '\t')" -f"${colnofrom}" "${inputfile}" |
+ linenofrom=$(cut -d"$tab" -f"${colnofrom}" "${inputfile}" |
grep -ni "${searchtextfrom}" |
sed 's/^\([0-9]\+\).*/\1/;1q')
# shellcheck disable=SC2140
- [ -z "$linenofrom" ] \
- && { error "not found \`${searchtextfrom}' in column "\
+ [ -z "$linenofrom" ] &&
+ { error "not found \`${searchtextfrom}' in column "\
"${colnofrom}"
exit 1; }
fi