git://git.nikiroo.be
/
gamiki.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
b336710
)
delete _HOME_ if not used after game is done
master
author
Niki Roo
<niki@nikiroo.be>
Tue, 30 Dec 2025 22:08:17 +0000
(23:08 +0100)
committer
Niki Roo
<niki@nikiroo.be>
Tue, 30 Dec 2025 22:08:17 +0000
(23:08 +0100)
gamiki/support/commands.py
patch
|
blob
|
blame
|
history
diff --git
a/gamiki/support/commands.py
b/gamiki/support/commands.py
index d0454e9b942124e27d386f4e5c94fc32c9f5c586..b6f872e7d6d01449c0506c31dd2640b8360a168d 100644
(file)
--- a/
gamiki/support/commands.py
+++ b/
gamiki/support/commands.py
@@
-1,6
+1,6
@@
from subprocess import run
from shutil import which
from subprocess import run
from shutil import which
-from os import environ, mkdir
+from os import environ, mkdir
, scandir
from pathlib import PurePath
__programs__: dict = { }
from pathlib import PurePath
__programs__: dict = { }
@@
-103,5
+103,14
@@
def start_sh(dir: PurePath, link: PurePath, opt: str = None) -> int:
env["HOME"] = home.as_posix()
cmd = startsh.as_posix()
env["HOME"] = home.as_posix()
cmd = startsh.as_posix()
- return run(cmd, cwd=dir, env=env).returncode
+ rc = run(cmd, cwd=dir, env=env).returncode
+
+ # Remove newly-created _HOME_ if it is still empty
+ if not any(scandir(home.as_posix())):
+ home.rmdir()
+
+ return rc
+
+ print("Directory is empty.")
+