diff --git a/preload.lua b/preload.lua index e905cb3..9c15a5d 100644 --- a/preload.lua +++ b/preload.lua @@ -1,10 +1,10 @@ -- The preload file initializes everything else for our shell --- Currently it just adds our builtins local fs = require 'fs' local commander = require 'commander' local bait = require 'bait' +-- Builtins commander.register('cd', function (args) bait.throw('cd', args) if #args > 0 then @@ -86,3 +86,8 @@ function string.split(str, delimiter) return result end +-- Hook handles +bait.catch('command.not-found', function(cmd) + print(string.format('hilbish: %s not found', cmd)) +end) + diff --git a/shell.go b/shell.go index 17e26b1..d2dbbbc 100644 --- a/shell.go +++ b/shell.go @@ -123,7 +123,7 @@ func execCommand(cmd string) error { } if _, err := interp.LookPathDir(hc.Dir, hc.Env, args[0]); err != nil { - fmt.Printf("hilbish: %s not found\n", args[0]) + hooks.Em.Emit("command.not-found", args[0]) return interp.NewExitStatus(127) }