在 Git Bash 中,如何修复“stdin 不是 tty”错误?

问题描述 投票:0回答:2

我在 Windows 10 上使用 Git Bash。我想导入一个 SQL 文件以在我的 PostGres 12 本地数据库中运行。我尝试了以下

$ PGPASSWORD=$DB_PASSWORD psql -U${DB_USER} $DB_NAME < scripts/my-script.sql
stdin is not a tty

当我查看数据库时,脚本尚未运行,这让我相信错误消息告诉了我原因,但我不确定它的含义或如何修复它。

windows-10 stdin psql git-bash tty
2个回答
5
投票

不要在 Windows 上使用重定向(一般来说,不仅仅是在“git-bash”中)。

使用

-f
参数传递脚本文件:

PGPASSWORD=$DB_PASSWORD psql -U${DB_USER} -f scripts/my-script.sql $DB_NAME

0
投票

用 psql.exe 替换 psql

这与 git-bash 提供的别名有关 - psql 是少数具有别名的程序之一。当我运行

cat  /etc/profile.d/aliases.sh
时,我看到这一行:

for name in node ipython php php5 psql python2.7 winget

欲了解更多信息,请查看以下链接:

© www.soinside.com 2019 - 2024. All rights reserved.