Command-Line

獲得隨機“cd:參數太多”。使用不同命令時的錯誤消息

  • December 11, 2018

我得到隨機的“cd:參數太多”。當使用不同的命令時,例如newgrp或登錄時。這是一個控制台日誌,顯示問題以及 Linux 版本和 shell 類型。

Last login: Mon Jun  4 10:50:58 2018 from somewhere.com
cd: Too many arguments.
myServerName /home/myUserName>
myServerName /home/myUserName>
myServerName /home/myUserName>
myServerName /home/myUserName>
myServerName /home/myUserName> groups
groupA groupB
myServerName /home/myUserName> newgrp groupB
cd: Too many arguments.
myServerName /home/myUserName> groups
groupB groupA
myServerName /home/myUserName> uname -or
2.6.32-696.13.2.el6.x86_64 GNU/Linux
myServerName /home/myUserName> lsb_release -irc
Distributor ID: RedHatEnterpriseServer
Release:        6.9
Codename:       Santiago
myServerName /home/myUserName> echo $0
tcsh
myServerName /home/myUserName>

newgrp命令實際上執行良好,但我仍然想擺脫這個消息。

不幸的是,線上搜尋沒有真正的結果,因為所有這些都與cd命令本身有關。

我歡迎在跟踪此問題方面提供一些幫助。

更新

myServerName /home/myUserName> grep "cd " ~/.tcshrc ~/.cshrc ~/.login
grep: /home/myUserName/.tcshrc: No such file or directory
myServerName /home/myUserName> grep "cd "  ~/.cshrc ~/.login
myServerName /home/myUserName>

~/.cshrc ~/.login 文件:

# ----------------------------------------------------------------------------                        |# ----------------------------------------------------------------------------G
# Name     : .login                                                                                   |# Name     : .cshrc
# Function : users startup-file for csh and tcsh                                                      |# Function : Users startup-file for csh and tcsh
#                                                                                                     |#
# Note     : Please do not edit this file until you have read the                                     |# Note     : Please do not edit this file until you have read the
#            site policy file for dot-files: /etc/home/README                                         |#            site policy file for dot-files: /etc/home/README.*
#                                                                                                     |#
# ----------------------------------------------------------------------------                        |# ----------------------------------------------------------------------------
if (-r /etc/home/login && -d /env) then                                                               |if (-r /etc/home/cshrc && -d /env) then
  source /etc/home/login                                                                             |   source /etc/home/cshrc
else                                                                                                  |else
  source .login.old                                                                                  |   source .cshrc.old
endif                                                                                                 |endif

問題出在 ~/.cshrc ~/.login 腳本中:

# ----------------------------------------------------------------------------    
# Name     : .login                                                               
# Function : users startup-file for csh and tcsh                                  
#                                                                                 
# Note     : Please do not edit this file until you have read the                 
#            site policy file for dot-files: /etc/home/README                     
#                                                                                 
# ----------------------------------------------------------------------------    
if (-r /etc/home/login && -d /env) then                                           
  source /etc/home/login                                                         
else                                                                              
  source .login.old                                                              
endif   

source命令被一個別名覆蓋,該別名是某個目錄的快捷方式。刪除別名解決了這個問題。

引用自:https://unix.stackexchange.com/questions/447803