[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Kludge for handling REPL arithmetic expressions
From: |
Greg Wooledge |
Subject: |
Re: Kludge for handling REPL arithmetic expressions |
Date: |
Wed, 4 Aug 2021 13:52:47 -0400 |
On Wed, Aug 04, 2021 at 08:36:41AM -0700, Eric Pruitt wrote:
> BASH_ALIASES[=]='calculate #'
> function calculate()
> {
> local result
>
> result="$(
> expression="$(HISTTIMEFORMAT= \history 1)"
> pc "x = $LAST_RESULT" "$(eval "echo \" ${expression#*=}\"")"
> )"
>
> test -n "$result" && LAST_RESULT="${result#* }" && echo "$result"
> }
Hah. That looks a lot like my "magic alias". You even found the same
"use BASH_ALIASES to make = an alias" trick, which I'd never seen
before today!