From 9ea1cd195c655a31d41ea31636e67a583f7ad1a5 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Fri, 2 Aug 2024 11:51:49 +0300 Subject: [PATCH] wip --- hbs2-cli/lib/Data/Config/Suckless/Script/File.hs | 3 +-- hbs2-cli/lib/Data/Config/Suckless/Script/Internal.hs | 5 +++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs b/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs index e5e6a0fe..220405a7 100644 --- a/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs +++ b/hbs2-cli/lib/Data/Config/Suckless/Script/File.hs @@ -40,8 +40,7 @@ glob pat ignore dir action = runContT (callCC $ \exit -> go exit dir) pure unless continue (exit ()) else do isD <- liftIO $ doesDirectoryExist fn - if not isD then exit () - else do + when isD do content <- liftIO (try @_ @IOError $ listDirectory fn) <&> fromRight mempty -- TODO: memory-hungry diff --git a/hbs2-cli/lib/Data/Config/Suckless/Script/Internal.hs b/hbs2-cli/lib/Data/Config/Suckless/Script/Internal.hs index 31479682..f4c0c8e2 100644 --- a/hbs2-cli/lib/Data/Config/Suckless/Script/Internal.hs +++ b/hbs2-cli/lib/Data/Config/Suckless/Script/Internal.hs @@ -867,6 +867,11 @@ internalEntries = do pure $ if a == b then mkBool True else mkBool False _ -> throwIO (BadFormException @c nil) + entry $ bindMatch "length" $ \case + [ListVal es] -> pure $ mkInt (length es) + [StringLike es] -> pure $ mkInt (length es) + _ -> pure $ mkInt 0 + entry $ bindMatch "nil?" $ \case [ListVal []] -> pure $ mkBool True _ -> pure $ mkBool False