So if you take a look at the script created by writeShellApplication
, it uses:
set -o errexit
set -o nounset
set -o pipefail
So the script will exit if any pipe fails. Since head
closes the pipe before tr
could read everything from /dev/urandom
, tr
will return exit status 141 and the script exits.
You can either disable pipefail for that line (set +o pipefail
) or add a || true
.
I’d probably write it like this:
pass="$(tr -dc "$characters" < /dev/urandom | head -c "$l" || true; echo)"