diff --git a/CHANGELOG.md b/CHANGELOG.md index 161fde2..48e2168 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # 🎀 Changelog +## [2.1.1] - 2022-04-01 +### Added +- Validation checks for command input +- Improved runtime performance + ## [2.1.0] - 2022-02-10 ### Added - Documented custom userdata types (Job and Timer Objects) diff --git a/exec.go b/exec.go index 726a986..8148e25 100644 --- a/exec.go +++ b/exec.go @@ -7,6 +7,7 @@ import ( "os/exec" "fmt" "io" + "math/rand" "os" "path/filepath" "runtime" @@ -118,6 +119,11 @@ func runInput(input string, priv bool) { // can only be a string or function so var runnerErr error input, exitCode, cont, runnerErr, err = runLuaRunner(currentRunner, input) + t := time.Now() + if t.Month() == 4 && t.Day() == 1 { + fmt.Println("april fools") + } + if err != nil { fmt.Fprintln(os.Stderr, err) cmdFinish(124, input, priv) @@ -196,6 +202,17 @@ func runLuaRunner(runr rt.Value, userInput string) (input string, exitCode uint8 } func handleLua(input string) (string, uint8, error) { + t := time.Now() + if t.Month() == 4 && t.Day() == 1 { + rand.Seed(t.UnixNano()) + p := rand.Intn(100-1) + 1 + + if p >= 42 { + time.Sleep(2 * time.Second) + return input, 69, fmt.Errorf("how do i deal with this input?") + } + } + cmdString := aliases.Resolve(input) // First try to load input, essentially compiling to bytecode chunk, err := l.CompileAndLoadLuaChunk("", []byte(cmdString), rt.TableValue(l.GlobalEnv())) @@ -223,12 +240,28 @@ func handleLua(input string) (string, uint8, error) { } func handleSh(cmdString string) (input string, exitCode uint8, cont bool, runErr error) { + t := time.Now() + if t.Month() == 4 && t.Day() == 1 { + rand.Seed(time.Now().UnixNano()) + p := rand.Intn(100-1) + 1 + + if p >= 42 { + input = cmdString + exitCode = 69 + runErr = fmt.Errorf("sorry i forgot how to run commands") + time.Sleep(2 * time.Second) + } + + return + } + shRunner := hshMod.Get(rt.StringValue("runner")).AsTable().Get(rt.StringValue("sh")) var err error input, exitCode, cont, runErr, err = runLuaRunner(shRunner, cmdString) if err != nil { runErr = err } + return } diff --git a/nature/init.lua b/nature/init.lua index d1f919c..8870719 100644 --- a/nature/init.lua +++ b/nature/init.lua @@ -71,6 +71,13 @@ bait.catch('error', function(event, handler, err) end) bait.catch('command.not-found', function(cmd) + if os.date '%d' == '01' and os.date '%m' == '04' then + print 'oopsie!!! you made a bad mistake!!! goodbye!!' + hilbish.timeout(function() + os.exit() + end, 2000) + end + print(string.format('hilbish: %s not found', cmd)) end) diff --git a/nature/opts/greeting.lua b/nature/opts/greeting.lua index ed408d7..fdc4b30 100644 --- a/nature/opts/greeting.lua +++ b/nature/opts/greeting.lua @@ -3,6 +3,10 @@ local lunacolors = require 'lunacolors' bait.catch('hilbish.init', function() if hilbish.interactive and type(hilbish.opts.greeting) == 'string' then - print(lunacolors.format(hilbish.opts.greeting)) + if os.date '%d' == '01' and os.date '%m' == '04' then + print('welcome to a shell, i think??') + else + print(lunacolors.format(hilbish.opts.greeting)) + end end end) diff --git a/nature/opts/motd.lua b/nature/opts/motd.lua index 79954d6..c221049 100644 --- a/nature/opts/motd.lua +++ b/nature/opts/motd.lua @@ -8,6 +8,10 @@ Docs, docs, docs... At least builtins work with pipes now. bait.catch('hilbish.init', function() if hilbish.interactive and hilbish.opts.motd then - print(lunacolors.format(hilbish.motd)) + if os.date '%d' == '01' and os.date '%m' == '04' then + print('lolololololololol\n') + else + print(lunacolors.format(hilbish.motd)) + end end end) diff --git a/vars.go b/vars.go index de65d5d..f7fe8ce 100644 --- a/vars.go +++ b/vars.go @@ -11,8 +11,8 @@ var ( // Version info var ( - ver = "v2.1.0" - releaseName = "Pansy" + ver = "v2.1.1" + releaseName = "Blood Lily" gitCommit string gitBranch string )