Compare commits

..

8 Commits

Author SHA1 Message Date
sammyette a68b488828
Merge eded38c7b5 into 41e5e3f789 2024-07-20 12:12:06 +05:30
sammyette 41e5e3f789
feat: commanders can exit via ctrl c (#313) 2024-07-19 18:46:46 -04:00
sammyette 826b0789cb
docs: promote midnight edition on main readme 2024-07-19 17:43:49 -04:00
sammyette bfa3b55542
chore: merge 2024-07-19 09:51:12 -04:00
sammyette f7e66bb957
docs: bump version requirement 2024-07-19 09:48:40 -04:00
sammyette d7ab887234
feat: allow builds for unix (#311) 2024-07-19 09:48:01 -04:00
youkwhd b24fc4a422
fix: check if no command passed to exec (#310)
* fix: check if no command passed to exec

* docs: add exec fixes

* chore: remove extra space
2024-07-10 10:04:15 -04:00
sammyette 0e4b95d9b9
fix: make -S flag set absolute path to hilbish 2024-06-25 16:48:32 -04:00
17 changed files with 59 additions and 15 deletions

View File

@ -29,7 +29,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.18.8'
go-version: '1.22.2'
- name: Download Task
run: 'sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d'
- name: Build

View File

@ -30,6 +30,9 @@ hilbish.run('wc -l', {
### Fixed
- Fix ansi attributes causing issues with text when cut off in greenhouse
- `exec` command should return if no arg presented
- Commanders can now be cancelled by Ctrl-C and wont hang the shell anymore.
See [issue 198](https://github.com/Rosettea/Hilbish/issues/198).
## [2.2.3] - 2024-04-27
### Fixed

View File

@ -1,3 +1,6 @@
> [!TIP]
> Check out [Hilbish: Midnight Edition](https://github.com/Rosettea/Hilbish/tree/midnight-edition) if you want to use C Lua, LuaJIT or anything related!
<img src="./assets/hilbish-logo-and-text.png" width=512><br>
<blockquote>
🌓 The Moon-powered shell! A comfy and extensible shell for Lua fans! 🌺 ✨
@ -36,7 +39,7 @@ on the website for distributed binaries from GitHub or other package repositorie
Otherwise, continue reading for steps on compiling.
## Prerequisites
- [Go 1.17+](https://go.dev)
- [Go 1.22+](https://go.dev)
- [Task](https://taskfile.dev/installation/) (**Go on the hyperlink here to see Task's install method for your OS.**)
## Build

30
exec.go
View File

@ -8,6 +8,7 @@ import (
"fmt"
"io"
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
@ -353,7 +354,34 @@ func execHandle(bg bool) interp.ExecHandlerFunc {
sinks.Set(rt.StringValue("out"), rt.UserDataValue(stdout.ud))
sinks.Set(rt.StringValue("err"), rt.UserDataValue(stderr.ud))
luaexitcode, err := rt.Call1(l.MainThread(), rt.FunctionValue(cmd), rt.TableValue(luacmdArgs), rt.TableValue(sinks))
t := rt.NewThread(l)
sig := make(chan os.Signal)
exit := make(chan bool)
luaexitcode := rt.IntValue(63)
var err error
go func() {
defer func() {
if r := recover(); r != nil {
exit <- true
}
}()
signal.Notify(sig, os.Interrupt)
select {
case <-sig:
t.KillContext()
return
}
}()
go func() {
luaexitcode, err = rt.Call1(t, rt.FunctionValue(cmd), rt.TableValue(luacmdArgs), rt.TableValue(sinks))
exit <- true
}()
<-exit
if err != nil {
fmt.Fprintln(os.Stderr, "Error in command:\n" + err.Error())
return interp.NewExitStatus(1)

View File

@ -1,4 +1,4 @@
// +build linux darwin
//go:build unix
package main

View File

@ -1,4 +1,4 @@
// +build windows
//go:build windows
package main

View File

@ -1,4 +1,4 @@
// +build windows
//go:build windows
package main

View File

@ -1,4 +1,4 @@
// +build darwin linux
//go:build unix
package main

View File

@ -1,4 +1,4 @@
// +build windows
//go:build windows
package main

View File

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"os/exec"
"os/user"
"path/filepath"
"runtime"
@ -115,7 +116,13 @@ func main() {
// Set $SHELL if the user wants to
if *setshflag {
os.Setenv("SHELL", os.Args[0])
os.Setenv("SHELL", "hilbish")
path, err := exec.LookPath("hilbish")
if err == nil {
os.Setenv("SHELL", path)
}
}
lr = newLineReader("", false)

View File

@ -1,5 +1,8 @@
local commander = require 'commander'
commander.register('exec', function(args)
if #args == 0 then
return
end
hilbish.exec(args[1])
end)

View File

@ -1,4 +1,4 @@
// +build pprof
//go:build pprof
package main

View File

@ -1,4 +1,4 @@
// +build darwin linux
//go:build unix
package main

View File

@ -1,4 +1,4 @@
// +build windows
//go:build windows
package main

View File

@ -1,4 +1,4 @@
// +build darwin
//go:build darwin
package main

View File

@ -1,4 +1,4 @@
// +build linux
//go:build unix && !darwin
package main

View File

@ -1,4 +1,4 @@
// +build windows
//go:build windows
package main