Add some debugging functions
This commit is contained in:
parent
253a43b45b
commit
d45f674711
5
functions/@
Normal file
5
functions/@
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/zsh
|
||||||
|
# for debugging: prefix any command with @ to print it before execution
|
||||||
|
function @() {
|
||||||
|
echo "$*"; "$@"
|
||||||
|
}
|
13
functions/parent-user
Normal file
13
functions/parent-user
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
function parent-user() {
|
||||||
|
pid=${1:-$$}
|
||||||
|
uid=${2:-$(piduser $pid)}
|
||||||
|
stat=($(</proc/${pid}/stat))
|
||||||
|
ppid=${stat[4]}; echo $ppid
|
||||||
|
puid=$(piduser $ppid )
|
||||||
|
|
||||||
|
if [[ ${puid} != $uid ]]; then
|
||||||
|
echo ${puid}
|
||||||
|
elif [[ $ppid != 1 ]]; then
|
||||||
|
parent-user ${ppid}
|
||||||
|
fi
|
||||||
|
}
|
Loading…
Reference in a new issue