SbarLua icon indicating copy to clipboard operation
SbarLua copied to clipboard

For sbar.exec(<cmd>, <callback>), <callback> is not called when <cmd> prints nothing

Open WantToLearnJapanese opened this issue 1 year ago • 3 comments

Currently, the simple workaround is appending && echo 1 to the \<cmd\>

WantToLearnJapanese avatar Apr 28 '24 07:04 WantToLearnJapanese

Hi, I meet a problem with the function too. It can not recive argument from , I think. I executed the example command

sbar.exec("sleep 5 && echo TEST", function(result)
 print(result)
end)

and return nothing. I wonder what's wrong with it. Can you test if it return "TEST" or nothing plz? plus, I'm using lua 5.4.6. Does it matter?

curiosusJR avatar May 14 '24 05:05 curiosusJR

@curiosusJR Sorry for the late reply. I can't access the macOS right now. But I am sure appending && echo 1 works. Since I actually used that for my scripts.

WantToLearnJapanese avatar May 16 '24 05:05 WantToLearnJapanese

I am checking for the built-in display which yields empty string if it doesn't find, so I appended: grep -q 'Built-in' && echo 'true' || echo 'false' works like a charm.

xavierchanth avatar May 18 '24 01:05 xavierchanth

Should be fixed. Exit code is now additionally send to the callback function: https://github.com/FelixKratz/SbarLua/commit/5cfb488806006230712e87da74d8e767072c5c29

FelixKratz avatar Aug 08 '24 16:08 FelixKratz