如何将stdin上的密码传递给psql和其他实用程序?

Met*_*ome 0 postgresql

可以通过在〜/ .pgpass中指定来完成传递密码.然而,我很好奇是否有办法使用stdin而不使用类似的东西expect.以下似乎不起作用:

psql -U postgres <<< "mypw"
Run Code Online (Sandbox Code Playgroud)