mirror of https://github.com/Hilbis/Hilbish
Compare commits
9 Commits
12828d197a
...
14e6ae5a3c
Author | SHA1 | Date |
---|---|---|
sammyette | 14e6ae5a3c | |
sammyette | a655ff00ce | |
sammyette | aa7de15997 | |
sammyette | aeac0ccce0 | |
sammyette | f31c1296ae | |
sammyette | 3a673e2a9b | |
sammyette | 03eefdc02e | |
sammyette | e0851809ab | |
sammyette | 1ff3ff854b |
11
Makefile
11
Makefile
|
@ -4,10 +4,13 @@ BINDIR ?= $(PREFIX)/bin
|
||||||
LIBDIR ?= $(PREFIX)/share/hilbish
|
LIBDIR ?= $(PREFIX)/share/hilbish
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@go build
|
@go build -ldflags "-s -w"
|
||||||
|
|
||||||
build-dev:
|
dev:
|
||||||
@go build -ldflags "-X main.version=$(git describe --tags)"
|
@go build -ldflags "-s -w -X main.version=$(shell git describe --tags)"
|
||||||
|
|
||||||
|
hilbiline:
|
||||||
|
@go build -ldflags "-s -w -X main.version=$(shell git describe --tags)+hilbiline" -tags hilbiline
|
||||||
|
|
||||||
install:
|
install:
|
||||||
@install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
|
@install -v -d "$(DESTDIR)$(BINDIR)/" && install -m 0755 -v hilbish "$(DESTDIR)$(BINDIR)/hilbish"
|
||||||
|
@ -28,4 +31,4 @@ clean:
|
||||||
|
|
||||||
all: build install
|
all: build install
|
||||||
|
|
||||||
.PHONY: install uninstall build build-dev clean
|
.PHONY: install uninstall build dev hilbiline clean
|
||||||
|
|
14
README.md
14
README.md
|
@ -51,15 +51,27 @@ sudo zypper install readline-devel
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
|
First, clone Hilbish:
|
||||||
```sh
|
```sh
|
||||||
git clone --recursive https://github.com/Hilbis/Hilbish
|
git clone --recursive https://github.com/Hilbis/Hilbish
|
||||||
cd Hilbish
|
cd Hilbish
|
||||||
make build
|
```
|
||||||
|
|
||||||
|
Then build and install:
|
||||||
|
```sh
|
||||||
|
make dev
|
||||||
sudo make install
|
sudo make install
|
||||||
# Or
|
# Or
|
||||||
sudo make all
|
sudo make all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Or, if you want the latest stable release:
|
||||||
|
```
|
||||||
|
git checkout $(git describe --tags `git rev-list --tags --max-count=1`)
|
||||||
|
make build
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
Alternatively, if you use Arch Linux, you can compile Hilbish with an **(unofficial)** AUR package:
|
Alternatively, if you use Arch Linux, you can compile Hilbish with an **(unofficial)** AUR package:
|
||||||
```sh
|
```sh
|
||||||
yay -S hilbish
|
yay -S hilbish
|
||||||
|
|
10
go.mod
10
go.mod
|
@ -3,13 +3,17 @@ module hilbish
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 // indirect
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
|
||||||
github.com/pborman/getopt v1.1.0
|
github.com/pborman/getopt v1.1.0
|
||||||
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
|
github.com/sergi/go-diff v1.0.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.4.0 // indirect
|
||||||
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
github.com/yuin/gopher-lua v0.0.0-20200816102855-ee81675732da
|
||||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
|
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
|
||||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56
|
||||||
layeh.com/gopher-luar v1.0.8
|
layeh.com/gopher-luar v1.0.8
|
||||||
mvdan.cc/sh/v3 v3.2.4
|
mvdan.cc/sh/v3 v3.3.0
|
||||||
)
|
)
|
||||||
|
|
22
go.sum
22
go.sum
|
@ -1,3 +1,5 @@
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4 h1:S9ulYwm5MUp02mEKnbDhVGjVBkdYV7/tmgEO1g3Q+Z8=
|
||||||
|
github.com/Hilbis/Hilbiline v0.0.0-20210416123506-f1b20c1c66e4/go.mod h1:mp9I7lvFoZ3ldAeydCzISakl6VdQYyrR8vVjmnKGqDo=
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e h1:4G8AYOOwZdDWOiJR6D6JXaFmj5BDS7c5D5PyqsG/+Hg=
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e h1:4G8AYOOwZdDWOiJR6D6JXaFmj5BDS7c5D5PyqsG/+Hg=
|
||||||
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e/go.mod h1:fmqtV+Wqx0uFYLN1F4VhjZdtT56Dr8c3yA7nALFsw/Q=
|
github.com/bobappleyard/readline v0.0.0-20150707195538-7e300e02d38e/go.mod h1:fmqtV+Wqx0uFYLN1F4VhjZdtT56Dr8c3yA7nALFsw/Q=
|
||||||
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9 h1:xz6Nv3zcwO2Lila35hcb0QloCQsc38Al13RNEzWRpX4=
|
||||||
|
@ -5,21 +7,32 @@ github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9/go.mod h1:2w
|
||||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
|
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
github.com/creack/pty v1.1.11 h1:07n33Z8lZxZ2qwegKbObQohDhXDQxiMMz1NOUGYlesw=
|
||||||
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/google/renameio v1.0.1-0.20210406141108-81588dbe0453/go.mod h1:t/HQoYBZSsWSNK35C6CO/TpPLDVWvxOHboWUAweKUpk=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
github.com/mattn/go-runewidth v0.0.12 h1:Y41i/hVW3Pgwr8gV+J23B9YEY0zxjptBuCWEaxmAOow=
|
||||||
|
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||||
github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
|
github.com/pborman/getopt v1.1.0 h1:eJ3aFZroQqq0bWmraivjQNt6Dmm5M0h2JcDW38/Azb0=
|
||||||
github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
|
github.com/pborman/getopt v1.1.0/go.mod h1:FxXoW1Re00sQG/+KIkuSqRL/LwQgSkv7uyac+STFsbk=
|
||||||
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
||||||
|
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/rivo/uniseg v0.1.0 h1:+2KBaVoUmb9XzDsrx/Ct0W/EYOSFf/nWTauy++DprtY=
|
||||||
|
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
|
github.com/rogpeppe/go-internal v1.7.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
@ -33,11 +46,17 @@ golang.org/x/sys v0.0.0-20190204203706-41f3e6584952/go.mod h1:STP8DvDyc/dI5b8T5h
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201029080932-201ba4db2418/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210414055047-fe65e336abe0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
|
||||||
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210503080704-8803ae5d1324/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=
|
||||||
|
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
golang.org/x/term v0.0.0-20191110171634-ad39bd3f0407/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
|
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 h1:VqE9gduFZ4dbR7XoL77lHFp0/DyDUBKSXK7CMFkVcV0=
|
||||||
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
|
||||||
|
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
@ -45,5 +64,8 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
layeh.com/gopher-luar v1.0.8 h1:Uqws1Z6T0vK6pZ7ehNNurLLSFcz7+E0EOHVM4FNiMQs=
|
layeh.com/gopher-luar v1.0.8 h1:Uqws1Z6T0vK6pZ7ehNNurLLSFcz7+E0EOHVM4FNiMQs=
|
||||||
layeh.com/gopher-luar v1.0.8/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk=
|
layeh.com/gopher-luar v1.0.8/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk=
|
||||||
mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8=
|
mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8=
|
||||||
|
mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0=
|
||||||
mvdan.cc/sh/v3 v3.2.4 h1:+fZaWcXWRjYAvqzEKoDhDM3DkxdDUykU2iw0VMKFe9s=
|
mvdan.cc/sh/v3 v3.2.4 h1:+fZaWcXWRjYAvqzEKoDhDM3DkxdDUykU2iw0VMKFe9s=
|
||||||
mvdan.cc/sh/v3 v3.2.4/go.mod h1:fPQmabBpREM/XQ9YXSU5ZFZ/Sm+PmKP9/vkFHgYKJEI=
|
mvdan.cc/sh/v3 v3.2.4/go.mod h1:fPQmabBpREM/XQ9YXSU5ZFZ/Sm+PmKP9/vkFHgYKJEI=
|
||||||
|
mvdan.cc/sh/v3 v3.3.0 h1:ujzElMnry63f4I5sjPFxzo6xia+gwsHZM0yyauuyZ6k=
|
||||||
|
mvdan.cc/sh/v3 v3.3.0/go.mod h1:dh3avhLDhJJ/MJKzbak6FYn+DJKUWk7Fb6Dh5mGdv6Y=
|
||||||
|
|
22
main.go
22
main.go
|
@ -12,7 +12,6 @@ import (
|
||||||
"hilbish/golibs/bait"
|
"hilbish/golibs/bait"
|
||||||
|
|
||||||
"github.com/pborman/getopt"
|
"github.com/pborman/getopt"
|
||||||
"github.com/bobappleyard/readline"
|
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"layeh.com/gopher-luar"
|
"layeh.com/gopher-luar"
|
||||||
"golang.org/x/term"
|
"golang.org/x/term"
|
||||||
|
@ -22,6 +21,7 @@ import (
|
||||||
var (
|
var (
|
||||||
version = "v0.4.0"
|
version = "v0.4.0"
|
||||||
l *lua.LState
|
l *lua.LState
|
||||||
|
lr *LineReader
|
||||||
|
|
||||||
prompt string // User's prompt, this will get set when lua side is initialized
|
prompt string // User's prompt, this will get set when lua side is initialized
|
||||||
multilinePrompt = "> "
|
multilinePrompt = "> "
|
||||||
|
@ -113,8 +113,7 @@ func main() {
|
||||||
RunLogin()
|
RunLogin()
|
||||||
RunConfig(*configflag)
|
RunConfig(*configflag)
|
||||||
|
|
||||||
readline.Completer = readline.FilenameCompleter
|
lr = NewLineReader("")
|
||||||
readline.LoadHistory(homedir + "/.hilbish-history")
|
|
||||||
|
|
||||||
if *cmdflag != "" {
|
if *cmdflag != "" {
|
||||||
RunInput(*cmdflag)
|
RunInput(*cmdflag)
|
||||||
|
@ -133,7 +132,8 @@ func main() {
|
||||||
for interactive {
|
for interactive {
|
||||||
running = false
|
running = false
|
||||||
|
|
||||||
input, err := readline.String(fmtPrompt())
|
lr.SetPrompt(fmtPrompt())
|
||||||
|
input, err := lr.Read()
|
||||||
|
|
||||||
if err == io.EOF {
|
if err == io.EOF {
|
||||||
// Exit if user presses ^D (ctrl + d)
|
// Exit if user presses ^D (ctrl + d)
|
||||||
|
@ -158,6 +158,7 @@ func main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
running = true
|
running = true
|
||||||
|
HandleHistory(input)
|
||||||
RunInput(input)
|
RunInput(input)
|
||||||
|
|
||||||
termwidth, _, err := term.GetSize(0)
|
termwidth, _, err := term.GetSize(0)
|
||||||
|
@ -170,7 +171,8 @@ func main() {
|
||||||
|
|
||||||
func ContinuePrompt(prev string) (string, error) {
|
func ContinuePrompt(prev string) (string, error) {
|
||||||
hooks.Em.Emit("multiline", nil)
|
hooks.Em.Emit("multiline", nil)
|
||||||
cont, err := readline.String(multilinePrompt)
|
lr.SetPrompt(multilinePrompt)
|
||||||
|
cont, err := lr.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -213,8 +215,14 @@ func HandleSignals() {
|
||||||
|
|
||||||
for range c {
|
for range c {
|
||||||
if !running {
|
if !running {
|
||||||
readline.ReplaceLine("", 0)
|
//readline.ReplaceLine("", 0)
|
||||||
readline.RefreshLine()
|
//readline.RefreshLine()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HandleHistory(cmd string) {
|
||||||
|
lr.AddHistory(cmd)
|
||||||
|
// TODO: load history again (history shared between sessions like this ye)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
-- The preload file initializes everything else for our shell
|
-- The preload file initializes everything else for our shell
|
||||||
-- Currently it just adds our builtins
|
|
||||||
|
|
||||||
local fs = require 'fs'
|
local fs = require 'fs'
|
||||||
local commander = require 'commander'
|
local commander = require 'commander'
|
||||||
local bait = require 'bait'
|
local bait = require 'bait'
|
||||||
|
|
||||||
|
-- Builtins
|
||||||
commander.register('cd', function (args)
|
commander.register('cd', function (args)
|
||||||
bait.throw('cd', args)
|
bait.throw('cd', args)
|
||||||
if #args > 0 then
|
if #args > 0 then
|
||||||
|
@ -86,3 +86,8 @@ function string.split(str, delimiter)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Hook handles
|
||||||
|
bait.catch('command.not-found', function(cmd)
|
||||||
|
print(string.format('hilbish: %s not found', cmd))
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
// +build !hilbiline
|
||||||
|
|
||||||
|
// Here we define a generic interface for readline and hilbiline,
|
||||||
|
// making them interchangable during build time
|
||||||
|
// this is normal readline
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/bobappleyard/readline"
|
||||||
|
|
||||||
|
type LineReader struct {
|
||||||
|
Prompt string
|
||||||
|
}
|
||||||
|
|
||||||
|
// other gophers might hate this naming but this is local, shut up
|
||||||
|
func NewLineReader(prompt string) *LineReader {
|
||||||
|
readline.Completer = readline.FilenameCompleter
|
||||||
|
readline.LoadHistory(homedir + "/.hilbish-history")
|
||||||
|
|
||||||
|
return &LineReader{
|
||||||
|
Prompt: prompt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) Read() (string, error) {
|
||||||
|
return readline.String(lr.Prompt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) SetPrompt(prompt string) {
|
||||||
|
lr.Prompt = prompt
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) AddHistory(cmd string) {
|
||||||
|
readline.AddHistory(cmd)
|
||||||
|
readline.SaveHistory(homedir + "/.hilbish-history")
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
// +build hilbiline
|
||||||
|
|
||||||
|
// Here we define a generic interface for readline and hilbiline,
|
||||||
|
// making them interchangable during build time
|
||||||
|
// this is hilbiline's, as is obvious by the filename
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "github.com/Hilbis/Hilbiline"
|
||||||
|
|
||||||
|
type LineReader struct {
|
||||||
|
hl *hilbiline.HilbilineState
|
||||||
|
}
|
||||||
|
|
||||||
|
// other gophers might hate this naming but this is local, shut up
|
||||||
|
func NewLineReader(prompt string) *LineReader {
|
||||||
|
hl := hilbiline.New(prompt)
|
||||||
|
|
||||||
|
return &LineReader{
|
||||||
|
&hl,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) Read() (string, error) {
|
||||||
|
return lr.hl.Read()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) SetPrompt(prompt string) {
|
||||||
|
lr.hl.SetPrompt(prompt)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lr *LineReader) AddHistory(cmd string) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
110
shell.go
110
shell.go
|
@ -5,8 +5,9 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/bobappleyard/readline"
|
// "github.com/bobappleyard/readline"
|
||||||
"github.com/yuin/gopher-lua"
|
"github.com/yuin/gopher-lua"
|
||||||
"github.com/yuin/gopher-lua/parse"
|
"github.com/yuin/gopher-lua/parse"
|
||||||
"layeh.com/gopher-luar"
|
"layeh.com/gopher-luar"
|
||||||
|
@ -15,18 +16,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func RunInput(input string) {
|
func RunInput(input string) {
|
||||||
cmdArgs, cmdString := splitInput(input)
|
_, cmdString := splitInput(input)
|
||||||
|
|
||||||
// If alias was found, use command alias
|
|
||||||
for aliases[cmdArgs[0]] != "" {
|
|
||||||
alias := aliases[cmdArgs[0]]
|
|
||||||
cmdString = alias + strings.TrimPrefix(cmdString, cmdArgs[0])
|
|
||||||
cmdArgs, cmdString = splitInput(cmdString)
|
|
||||||
|
|
||||||
if aliases[cmdArgs[0]] != "" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// First try to load input, essentially compiling to bytecode
|
// First try to load input, essentially compiling to bytecode
|
||||||
fn, err := l.LoadString(cmdString)
|
fn, err := l.LoadString(cmdString)
|
||||||
|
@ -45,43 +35,10 @@ func RunInput(input string) {
|
||||||
err = l.PCall(0, lua.MultRet, nil)
|
err = l.PCall(0, lua.MultRet, nil)
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// If it succeeds, add to history and prompt again
|
|
||||||
HandleHistory(input)
|
|
||||||
|
|
||||||
hooks.Em.Emit("command.exit", 0)
|
hooks.Em.Emit("command.exit", 0)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// If command is defined in Lua then run it
|
|
||||||
if commands[cmdArgs[0]] {
|
|
||||||
err := l.CallByParam(lua.P{
|
|
||||||
Fn: l.GetField(
|
|
||||||
l.GetTable(
|
|
||||||
l.GetGlobal("commanding"),
|
|
||||||
lua.LString("__commands")),
|
|
||||||
cmdArgs[0]),
|
|
||||||
NRet: 1,
|
|
||||||
Protect: true,
|
|
||||||
}, luar.New(l, cmdArgs[1:]))
|
|
||||||
luaexitcode := l.Get(-1)
|
|
||||||
exitcode := lua.LNumber(0)
|
|
||||||
|
|
||||||
l.Pop(1)
|
|
||||||
|
|
||||||
if code, ok := luaexitcode.(lua.LNumber); luaexitcode != lua.LNil && ok {
|
|
||||||
exitcode = code
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
fmt.Fprintln(os.Stderr,
|
|
||||||
"Error in command:\n\n" + err.Error())
|
|
||||||
}
|
|
||||||
if cmdArgs[0] != "exit" {
|
|
||||||
HandleHistory(cmdString)
|
|
||||||
}
|
|
||||||
hooks.Em.Emit("command.exit", exitcode)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Last option: use sh interpreter
|
// Last option: use sh interpreter
|
||||||
err = execCommand(cmdString)
|
err = execCommand(cmdString)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -113,7 +70,6 @@ func RunInput(input string) {
|
||||||
} else {
|
} else {
|
||||||
hooks.Em.Emit("command.exit", 0)
|
hooks.Em.Emit("command.exit", 0)
|
||||||
}
|
}
|
||||||
HandleHistory(cmdString)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run command in sh interpreter
|
// Run command in sh interpreter
|
||||||
|
@ -122,8 +78,60 @@ func execCommand(cmd string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exechandle := func(ctx context.Context, args []string) error {
|
||||||
|
hc := interp.HandlerCtx(ctx)
|
||||||
|
args, argstring := splitInput(strings.Join(args, " "))
|
||||||
|
|
||||||
|
// If alias was found, use command alias
|
||||||
|
for aliases[args[0]] != "" {
|
||||||
|
alias := aliases[args[0]]
|
||||||
|
argstring = alias + strings.TrimPrefix(argstring, args[0])
|
||||||
|
args, argstring = splitInput(argstring)
|
||||||
|
|
||||||
|
if aliases[args[0]] != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If command is defined in Lua then run it
|
||||||
|
if commands[args[0]] {
|
||||||
|
err := l.CallByParam(lua.P{
|
||||||
|
Fn: l.GetField(
|
||||||
|
l.GetTable(
|
||||||
|
l.GetGlobal("commanding"),
|
||||||
|
lua.LString("__commands")),
|
||||||
|
args[0]),
|
||||||
|
NRet: 1,
|
||||||
|
Protect: true,
|
||||||
|
}, luar.New(l, args[1:]))
|
||||||
|
luaexitcode := l.Get(-1)
|
||||||
|
var exitcode uint8 = 0
|
||||||
|
|
||||||
|
l.Pop(1)
|
||||||
|
|
||||||
|
if code, ok := luaexitcode.(lua.LNumber); luaexitcode != lua.LNil && ok {
|
||||||
|
exitcode = uint8(code)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Fprintln(os.Stderr,
|
||||||
|
"Error in command:\n\n" + err.Error())
|
||||||
|
}
|
||||||
|
hooks.Em.Emit("command.exit", exitcode)
|
||||||
|
return interp.NewExitStatus(exitcode)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err := interp.LookPathDir(hc.Dir, hc.Env, args[0]); err != nil {
|
||||||
|
hooks.Em.Emit("command.not-found", args[0])
|
||||||
|
return interp.NewExitStatus(127)
|
||||||
|
}
|
||||||
|
|
||||||
|
return interp.DefaultExecHandler(2*time.Second)(ctx, args)
|
||||||
|
}
|
||||||
runner, _ := interp.New(
|
runner, _ := interp.New(
|
||||||
interp.StdIO(os.Stdin, os.Stdout, os.Stderr),
|
interp.StdIO(os.Stdin, os.Stdout, os.Stderr),
|
||||||
|
interp.ExecHandler(exechandle),
|
||||||
)
|
)
|
||||||
err = runner.Run(context.TODO(), file)
|
err = runner.Run(context.TODO(), file)
|
||||||
|
|
||||||
|
@ -139,7 +147,7 @@ func splitInput(input string) ([]string, string) {
|
||||||
cmdArgs := []string{}
|
cmdArgs := []string{}
|
||||||
sb := &strings.Builder{}
|
sb := &strings.Builder{}
|
||||||
cmdstr := &strings.Builder{}
|
cmdstr := &strings.Builder{}
|
||||||
lastcmd := readline.GetHistory(readline.HistorySize() - 1)
|
lastcmd := "" //readline.GetHistory(readline.HistorySize() - 1)
|
||||||
|
|
||||||
for _, r := range input {
|
for _, r := range input {
|
||||||
if r == '"' {
|
if r == '"' {
|
||||||
|
@ -183,9 +191,3 @@ func splitInput(input string) ([]string, string) {
|
||||||
return cmdArgs, cmdstr.String()
|
return cmdArgs, cmdstr.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandleHistory(cmd string) {
|
|
||||||
readline.AddHistory(cmd)
|
|
||||||
readline.SaveHistory(homedir + "/.hilbish-history")
|
|
||||||
// TODO: load history again (history shared between sessions like this ye)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue