ExecContext: Fix output handling #9

Merged
Jan Lindemann merged 5 commits from jan/fix/20260610-lib-execcontext-put-fix-forgotten-input into master 2026-06-10 13:08:29 +02:00 AGit
2 changed files with 2 additions and 2 deletions
Showing only changes of commit 4a6c8ab1d1 - Show all commits

lib.ExecContext|.Distro: Ignore stdout_str newline

Ignore newline at the end of Result.stdout_str if only one line of output is wanted from an executed shell command. The output of both uname and mktemp are used wrongly in that regard.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-06-10 11:54:03 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -78,7 +78,7 @@ class Distro(abc.ABC):
), ),
) )
raise raise
uname = result.stdout_str.lower() uname = result.stdout_str.strip().lower()
ret = f'ID={uname}\nVERSION_CODENAME=unknown' ret = f'ID={uname}\nVERSION_CODENAME=unknown'
return ret return ret

View file

@ -588,7 +588,7 @@ class ExecContext(Base):
raise Exception( raise Exception(
f'Failed to create temporary file on {self.root}: {result.summary}' f'Failed to create temporary file on {self.root}: {result.summary}'
) )
return result.stdout_str return result.stdout_str.strip()
async def _stat(self, path: str, follow_symlinks: bool) -> StatResult: async def _stat(self, path: str, follow_symlinks: bool) -> StatResult: