dundalek / closh

Bash-like shell based on Clojure
Eclipse Public License 1.0
1.61k stars 65 forks source link

Implements alias expansion for JVM #150

Closed djblue closed 4 years ago

djblue commented 4 years ago

Fixes #106

dundalek commented 4 years ago

wow, that was fast!

I am pretty busy this week, but will hopefully be able to take a closer look and test it over the weekend.

dundalek commented 4 years ago

Very nice, works great :+1:

I found an issue for multi-line cases, here's a sample case:

;; Lets define a sample var and access its value
closh $ (def hi "hello")
#'user/hi
closh $ (str hi)
"hello"
closh $ (str
   #_=>  hi
   #_=>  )
"hello"

;; Bug: By introducing an alias we will shadow a variable even inside clojure form
;; (Because we process input on per line basis)
closh $ (defalias hi "echo hi")
closh $ (str
   #_=>  hi
   #_=>  )
Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: echo in this context

But the case is kind of artificial and not very likely to be encountered, so I am thinking of merging the PR as is and opening an issue to be tackled later (with other multi-line fixes or when the time will come for custom grammar implementation).