get rid of ed invocation, also to kill bug with cards containing "**"

This commit is contained in:
YargoB 2020-09-21 12:26:26 +00:00
parent bd118a4780
commit d8ab8e5105
1 changed files with 21 additions and 18 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
# clikan.sh -- CLI Kanban
ver='2020-05-11/HB9KNS'
ver='2020-09-21/HB9KNS'
conf="${CLIKANCONF:-$HOME/.clikanconf}"
defkanban="$HOME/clikanban.md"
@ -10,9 +10,10 @@ editor="${editor:-ed}"
myshell='/bin/sh -c'
filtr='.'
tmpf=`mktemp -t clikanXXXXXX` || tmpf=${TMPDIR:-/tmp}/clikan$$`date +%S%M%d`
: >$tmpf
chmod 600 $tmpf
buff=`mktemp -t clikanbXXXXXX` || buff=${TMPDIR:-/tmp}/clikanb$$`date +%S%M%d`
self=`mktemp -t clikantXXXXXX` || self=${TMPDIR:-/tmp}/clikant$$`date +%S%M%d`
chmod 600 $self $buff
: >$self
if test ! -f "$conf"
then cat <<EOT
@ -65,15 +66,15 @@ getlines(){
}
}
# display selection, and put selection list in tempfile,
# display selection, and put selection list in selection file,
# input through stdin, with lines prepended with index number, TAB and arg1
showselect(){
local i
i=1
: >$tmpf
: >$self
while read l
do echo $i: $l
echo "$i $1$l" >>$tmpf
echo "$i $1$l" >>$self
i=$(( $i+1 ))
done
}
@ -87,7 +88,7 @@ getselect(){
read i
if test "$i" = ""
then echo "$1"
else getlines $i <$tmpf
else getlines $i <$self
fi
}
@ -150,13 +151,14 @@ repline(){
shift
newl="$*"
for ff in $kbs
do cat <<EOC | ed "$ff" >/dev/null 2>&1
%g $patt c\\
$newl\\
.
w
q
EOC
do cat "$ff" > $buff
cat $buff | { while read oldl
do if test "$oldl" = "$patt"
then echo "$newl"
else echo "$oldl"
fi
done
} > "$ff"
done
}
@ -217,7 +219,7 @@ do|wait|done) if test "$coa1" = ""
coar=`echo "$coa1 $coa2 $coa3 $coar" | sed -e 's/ *$/ /'`
while test "$coar" != ""
do
coa1=`getlines ${coar%% *} <$tmpf`
coa1=`getlines ${coar%% *} <$self`
stamp=''
case $com in
done) coa2='+'
@ -245,7 +247,8 @@ n) newc=`echo "$coa1 $coa2 $coa3 $coar" | sed -e 's/ *$//'`
fi
if test "$newc" != ""
# replace all tabs by spaces (otherwise issue with ed pattern in repline)
then echo '-' "$newc" | sed -e 's/ / /g' >>$currkan
# then echo '-' "$newc" | sed -e 's/ / /g' >>$currkan
then echo '-' "$newc" >>$currkan
else echo no content found, nothing added
fi
showall doing
@ -270,4 +273,4 @@ showprompt
done
echo
rm -f $tmpf
rm -f $self $buff