liverepl

Evaluer ses scripts en temps réel (dangereux ⚠️) - retour accueil

git clone git://bebou.netlib.re/liverepl
Log | Files | Refs | README |

commit f1a317b4965461fbfc08ece6c7ba6a7c9882afc0
parent f72d2ba44473cee7907e2b21cdbba97cf56df892
Auterice: Arthur Pons <arthur.pons@unistra.fr>
Date:   Wed, 28 Aug 2024 23:12:07 +0200

Stockage de la commande tapée

Diffstat:
Mliverepl | 11++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/liverepl b/liverepl @@ -1,8 +1,8 @@ #! /bin/zsh -while getopts "fi:o:c:" opt;do +while getopts "fi:o:c:s:" opt;do case $opt in - (i|o|c) + (i|o|c|s) eval "$opt='$OPTARG'";; (f) filter="yes" @@ -17,7 +17,7 @@ entry="" key="" echo -n "\033[?25l" 1>&2 -[ "$filter" = "yes" -a "$tmpf" = "-" ] && {tmpf=$(mktemp);cat > $tmpf;} +[ "$filter" = "yes" -a "$tmpf" = "-" ] && { tmpf=$(mktemp); cat > $tmpf; } saveanddisp() { tee $tmpres | head -n$(( $(tput lines) - 2 )) 1>&2 } @@ -29,9 +29,9 @@ dispprompt() { managekey() { case "$key" in - () [ "${#entry}" -gt 0 ] && entry=${entry::-1};; - () entry="";; + () [ "${#entry}" -gt "0" ] && entry="${entry%?}";; (|$'\n') break;; + () entry="";; (*) entry="$entry$key";; esac } @@ -54,6 +54,7 @@ while :;do eval "$entry" | saveanddisp fi key="" + [ -n "$s" ] && echo "$entry" > $s dispprompt; read -t1 -k1 key; managekey done clear