为什么在 csh 中输出重定向期间出现“不是终端”错误?

为什么在 csh 中输出重定向期间出现“不是终端”错误?

背景:

我们已将一些命令输出(stdout 和 stderr)放入cshshell 下的同一文件中。

问题:

为什么我们在以下重定向标头中收到“不是终端”消息?

> which brarchive
/home/ewpadm/brtools/brarchive
> 
> 
> which brarchive  >& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
> 
> 
> ls -l Ac >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
> 
> 
> (which pwd; ls -l Fc) >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
> 
> 
> (which tar; file /etc/passwd) >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
Not a terminal
/usr/bin/tar
/etc/passwd: ascii text
> 
> 
> (which ntpq; head -1 /etc/ntp.conf) >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
Not a terminal
/usr/bin/tar
/etc/passwd: ascii text
Not a terminal
which: 0652-141 There is no ntpq in /oracle/EWP/112_64/bin /usr/bin /etc /usr/sbin /usr/ucb /home/ewpadm/bin /usr/bin/X11 /sbin . /usr/sap/EWP/SYS/exe/uc/rs6000_64 /usr/sap/EWP/SYS/exe/run /home/ewpadm /home/ewpadm/brtools.
# @(#)48        1.2  src/tcpip/etc/ntp.conf, ntp, tcpip610 2/16/96 10:16:34
> 
> 
> ls -l Ac >>& t_0                           
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
Not a terminal
/usr/bin/tar
/etc/passwd: ascii text
Not a terminal
which: 0652-141 There is no ntpq in /oracle/EWP/112_64/bin /usr/bin /etc /usr/sbin /usr/ucb /home/ewpadm/bin /usr/bin/X11 /sbin . /usr/sap/EWP/SYS/exe/uc/rs6000_64 /usr/sap/EWP/SYS/exe/run /home/ewpadm /home/ewpadm/brtools.
# @(#)48        1.2  src/tcpip/etc/ntp.conf, ntp, tcpip610 2/16/96 10:16:34
ls: 0653-341 The file Ac does not exist.
> 
> 
> (ls -l Ac; file /etc/passwd) >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
Not a terminal
/usr/bin/tar
/etc/passwd: ascii text
Not a terminal
which: 0652-141 There is no ntpq in /oracle/EWP/112_64/bin /usr/bin /etc /usr/sbin /usr/ucb /home/ewpadm/bin /usr/bin/X11 /sbin . /usr/sap/EWP/SYS/exe/uc/rs6000_64 /usr/sap/EWP/SYS/exe/run /home/ewpadm /home/ewpadm/brtools.
# @(#)48        1.2  src/tcpip/etc/ntp.conf, ntp, tcpip610 2/16/96 10:16:34
ls: 0653-341 The file Ac does not exist.
ls: 0653-341 The file Ac does not exist.
/etc/passwd: ascii text
> 
> 
> (file /etc/passwd; ls -l Ac) >>& t_0
> 
> 
> cat t_0
Not a terminal
/home/ewpadm/brtools/brarchive
ls: 0653-341 The file Ac does not exist.
Not a terminal
/usr/bin/pwd
ls: 0653-341 The file Fc does not exist.
Not a terminal
/usr/bin/tar
/etc/passwd: ascii text
Not a terminal
which: 0652-141 There is no ntpq in /oracle/EWP/112_64/bin /usr/bin /etc /usr/sbin /usr/ucb /home/ewpadm/bin /usr/bin/X11 /sbin . /usr/sap/EWP/SYS/exe/uc/rs6000_64 /usr/sap/EWP/SYS/exe/run /home/ewpadm /home/ewpadm/brtools.
# @(#)48        1.2  src/tcpip/etc/ntp.conf, ntp, tcpip610 2/16/96 10:16:34
ls: 0653-341 The file Ac does not exist.
ls: 0653-341 The file Ac does not exist.
/etc/passwd: ascii text
/etc/passwd: ascii text
ls: 0653-341 The file Ac does not exist.
> 
> 


现在我可以确认这个错误消息只是通过 >& 的 stderr 输出获得的。
>
> which ssh > t_1
>                         
>                         
> cat t_1                 
 /usr/bin/ssh 
> 
>                                          
> (which ssh > t_1) >& t_2
>                         
>                         
> cat t_1                 
 /usr/bin/ssh                              
>                         
>                         
> cat t_2                 
 Not a terminal                            
>  

所以我的问题是为什么只有通过 ">&" 的 stderr 输出会产生错误,而通过 ">" 的 stderr 输出不会产生错误?

相关内容