~strahinja/ste

4376a2e13d15080edac40ea95d2ce4951d98bb47 — Страхиња Радић 8 months ago c4cec2c v0.4.1
Fix bug in sed regex; be less chatty when no vipe

Signed-off-by: Страхиња Радић <contact@strahinja.org>
2 files changed, 19 insertions(+), 5 deletions(-)

M ste.in
M tsvselect
M ste.in => ste.in +17 -4
@@ 157,7 157,14 @@ fi

# shellcheck disable=SC2065
if test ! -r "$file" >/dev/null 2>&1; then
	${insprog} "$file"
	if [ "$editfilter" ]; then
		printf '# New file - enter column headers, one per line\n\n' |
		${editfilter} | ${insprog} "$file"
	else
		#error "warning: vipe not detected"
		printf '# New file - enter column headers, one per line\n'
		cat | ${insprog} "$file"
	fi
fi
# shellcheck disable=SC2065
if test ! -r "$file" >/dev/null 2>&1; then


@@ 166,6 173,7 @@ if test ! -r "$file" >/dev/null 2>&1; then
fi

running=1
donevipewarn=0
currow=0
firstrow=0
nextcmd=''


@@ 234,6 242,11 @@ while [ "$running" -eq 1 ]; do
				print '\""$sgi"'7m'\"' $0 '\""$sgi"'0m'\"'
			else print
		}'
		if [ "$donevipewarn" -eq 0 ] && [ ! "$editfilter" ]; then
			error "warning: vipe not detected; input will be read \
directly from stdin"
			donevipewarn=1
		fi
		redraw=0
	fi



@@ 386,7 399,7 @@ while [ "$running" -eq 1 ]; do
					${editfilter} |
					${insprog} "$file" "$((currow))"
			else
				error "warning: vipe not detected"
				#error "warning: vipe not detected"
				${selprog} "$file" "$((maxrows + 1))"
				cat | ${insprog} "$file" "$((currow))"
			fi


@@ 396,7 409,7 @@ while [ "$running" -eq 1 ]; do
					${editfilter} |
					${insprog} "$file" "$((currow + 1))"
			else
				error "warning: vipe not detected"
				#error "warning: vipe not detected"
				${selprog} "$file" "$((maxrows + 1))"
				cat | ${insprog} "$file" "$((currow + 1))"
			fi


@@ 407,7 420,7 @@ while [ "$running" -eq 1 ]; do
					${editfilter} |
					${insprog} "$file"
			else
				error "warning: vipe not detected"
				#error "warning: vipe not detected"
				${selprog} "$file" "$((maxrows + 1))"
				cat | ${insprog} "$file"
			fi

M tsvselect => tsvselect +2 -1
@@ 80,7 80,8 @@ if [ "${numlines}" -gt 0 ]; then
			head -n"${lineno}" -- "${inputfile}" | tail -n1
		else
			sed 1q "${inputfile}" |
				sed -e 's/[^'"$tab"']*\('"$tab"'\?\)/\1/g'
				sed -e 's/[^'"$tab"']*\('"$tab"'\)/\1/g' \
				    -e 's/[^'"$tab"']*$//'
		fi; } |
	transpose - | sed -e 's/'"$tab"'/\'"$nl"'/g'
fi