чување db01fa32d587cb291dfa5487299d2ec899d945ff
родитељ f6a86d2edd4b36a4e12417b34d2882e8c4ea548e
Аутор: Страхиња Радић <contact@strahinja.org>
Датум: Sun, 17 Sep 2023 10:21:32 +0200
ste.in: Bugfix: Handle C-D properly; rename continue variable to running
Signed-off-by: Страхиња Радић <contact@strahinja.org>
Diffstat:
измењених датотека: 1, додавања: 7(+), брисања: 4(-)
diff --git a/ste.in b/ste.in
@@ -160,7 +160,7 @@ if test ! -r "$file" >/dev/null 2>&1; then
exit 1
fi
-continue=1
+running=1
currow=0
firstrow=0
nextcmd=''
@@ -170,7 +170,7 @@ redraw=1
sgi=$(printf "%b" "\033[")
maxcols=$(sed 1q "$file" | tr -dc '\t' | wc -c | awk '{print $1+1}')
-while [ "$continue" -eq 1 ]; do
+while [ "$running" -eq 1 ]; do
maxrows=$(wc -l "$file" | awk '{print $1}')
_cols="$cols"
if [ "$cols" -eq 0 ]; then
@@ -236,7 +236,10 @@ while [ "$continue" -eq 1 ]; do
if command -v rlwrap >/dev/null; then
cmd=$(rlwrap -H "$historyfile" -s 1000 -D 2 -I -o \
-S "${file##*/}[${_cols}x${_rows}+${firstrow}"\
-"@${currow}/${maxrows}]> " cat)
+"@${currow}/${maxrows}]> " sh -c 'IFS= read -r CMD && printf "%s\n" "$CMD"')
+ if [ "$?" -ne 0 ]; then
+ cmd=exit
+ fi
else
printf "%s[%dx%d+%d@%d/%d]> " \
"${file##*/}" "$_cols" "$_rows" "$firstrow" \
@@ -341,7 +344,7 @@ while [ "$continue" -eq 1 ]; do
edit|e) ${editprog} "$file" "$((currow + 1))"
redraw=1
;;
- exit|q) continue=0
+ exit|q) running=0
;;
G) currow=$((maxrows - 1))
redraw=1