#!/bin/execlineb
# Launched by s6-sudo with:
# FD 0: PTY master device (passed in by the client)
# FD 1,2: stdout/stderr of the client
# FD 4: s6-sudo service stderr
# argv as passed in by the client

fdmove -c 2 4  # restore stderr
fdmove 1 4  # copy to stdout
fdmove 3 0  # move ptmx to FD 3
redirfd -r 0 /dev/null  # open /dev/null for stdin
importas -D unnamed NAME 1  # get first positional argument, falling back to "unnamed"
importas -D "-" CAP capability_v0  # expose the env string (for debugging)
background { urxvt -name ${NAME}:${CAP} -pty-fd 3 }