2017-09-26 19:08:25 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
PANE_PID="$1"
|
2019-12-17 16:04:45 +00:00
|
|
|
COMMAND_PID=$(pgrep -P $PANE_PID)
|
2017-09-26 19:08:25 +00:00
|
|
|
|
|
|
|
exit_safely_if_empty_ppid() {
|
|
|
|
if [ -z "$PANE_PID" ]; then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
full_command() {
|
2019-12-17 16:04:45 +00:00
|
|
|
[[ -z "$COMMAND_PID" ]] && exit 0
|
2022-08-16 12:57:39 +00:00
|
|
|
# See: https://unix.stackexchange.com/a/567021
|
|
|
|
# Avoid complications with system printf by using bash subshell interpolation.
|
|
|
|
# This will properly escape sequences and null in cmdline.
|
|
|
|
cat /proc/${COMMAND_PID}/cmdline | xargs -0 bash -c 'printf "%q " "$0" "$@"'
|
2017-09-26 19:08:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
exit_safely_if_empty_ppid
|
|
|
|
full_command
|
|
|
|
}
|
|
|
|
main
|