From ae06283a7c168959632390f544ee52baaee2a2ec Mon Sep 17 00:00:00 2001 From: Andrew Davis Date: Fri, 21 Mar 2025 17:02:19 -0400 Subject: [PATCH] allow escaped shell vars like '${\1:?foo}' --- micro-snippets-plugin/snippets.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/micro-snippets-plugin/snippets.lua b/micro-snippets-plugin/snippets.lua index d5d71b3..0fd30e3 100644 --- a/micro-snippets-plugin/snippets.lua +++ b/micro-snippets-plugin/snippets.lua @@ -1,4 +1,4 @@ -VERSION = "0.2.0" +VERSION = "0.2.1" local micro = import("micro") local buffer = import("micro/buffer") @@ -212,6 +212,10 @@ function Snippet.Prepare(self) placeHolders.value = value end end + -- allow escaped shell vars like '${\1:?foo}' + -- str:gsub(ptn, repl[, num]) + local esc_ptn = "(${)\\(%d+:?[^}]*})" + self.code = self.code:gsub(esc_ptn, "%1%2") end end