From 62aae7ccc31aee754d619ca25c40b8f470b29596 Mon Sep 17 00:00:00 2001 From: voidlizard Date: Wed, 19 Feb 2025 11:29:31 +0300 Subject: [PATCH] runnable bf6 scripts with shebangs --- Makefile | 1 - .../lib/Data/Config/Suckless/Script/Internal.hs | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a702b667..63d08110 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,6 @@ BINS := \ hbs2-keyman \ hbs2-git-subscribe \ git-remote-hbs2 \ - git-hbs2 \ hbs2-cli \ hbs2-sync \ fixme-new \ diff --git a/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs b/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs index e2a65e80..671306d3 100644 --- a/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs +++ b/miscellaneous/suckless-conf/lib/Data/Config/Suckless/Script/Internal.hs @@ -1522,6 +1522,21 @@ internalEntries = do _ -> throwIO (BadFormException @c nil) + let dropShebang = id + + -- skips shebang + entry $ bindMatch "top:file:run" $ nil_ $ \case + (StringLike fn : args) -> do + liftIO (TIO.readFile fn) + <&> either (error.show) (fmap (fixContext @C @c) . dropShebang ) . parseTop + <&> \case + (ListVal (SymbolVal "#!" : _) : rest) -> rest + rest -> rest + >>= evalTop + + _ -> throwIO (BadFormException @c nil) + + brief "parses string as toplevel and produces a form" $ desc "parse:top:string SYMBOL STRING-LIKE" $ entry $ bindMatch "parse:top:string" $ \case