From 45d6f5d412df4e4d78beb61a79955c0b1389a07b Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sun, 26 May 2024 17:40:17 +0200 Subject: [PATCH] fix(cmd): initialize cache correctly resolves #4959 --- src/shell/scripts/omp.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/shell/scripts/omp.lua b/src/shell/scripts/omp.lua index 5ea46270..7dea9eb4 100644 --- a/src/shell/scripts/omp.lua +++ b/src/shell/scripts/omp.lua @@ -6,6 +6,18 @@ if '::UPGRADE::' == 'true' then print(notice) end +-- Cache PID + +function generateCustomUUID() + local template = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' + return string.gsub(template, '[x]', function(c) + local v = math.random(0, 0xf) + return string.format('%x', v) + end) +end + +os.setenv("POSH_PID", generateCustomUUID()) + -- Helper functions local function get_priority_number(name, default) @@ -25,11 +37,11 @@ local function get_priority_number(name, default) return default end end - +os.setenv("POSH_CURSOR_LINE", console.getnumlines()) -- Environment variables local function environment_onbeginedit() - os.setenv("POSH_CURSOR_LINE", console.getnumlines()) + end -- Local state