New hook 'destroyed-symlinks' to detect symlinks which are changed to regular files with a content of a path which that symlink was pointing to; move zsplit to util

This commit is contained in:
Mikhail Khvoinitsky
2020-08-02 21:25:07 +03:00
committed by Anthony Sottile
parent 14e9f0e512
commit 1e87d59a2d
9 changed files with 204 additions and 18 deletions

View File

@ -1,5 +1,6 @@
import subprocess
from typing import Any
from typing import List
from typing import Optional
from typing import Set
@ -22,3 +23,11 @@ def cmd_output(*cmd: str, retcode: Optional[int] = 0, **kwargs: Any) -> str:
if retcode is not None and proc.returncode != retcode:
raise CalledProcessError(cmd, retcode, proc.returncode, stdout, stderr)
return stdout
def zsplit(s: str) -> List[str]:
s = s.strip('\0')
if s:
return s.split('\0')
else:
return []