You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

source Oracle环境配置文件时出现“cd: too many arguments”错误的排查求助

source Oracle环境配置文件时出现“cd: too many arguments”错误的排查求助

大家好,我遇到了一个很奇怪的问题,想请各位帮忙分析排查下。

正常情况下,我以oracle用户身份执行source ~/.bash_profile是完全没问题的,但最近我为另一个实例创建了名为test的配置文件,内容如下:

#!/bin/bash

# User specific environment and startup programs

# Oracle Settings

# User specific environment and startup programs

if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]]

then

PATH="$HOME/.local/bin:$HOME/bin:$PATH"

fi

#export PATH

# Oracle Settings

export ORACLE_BASE=/opt/oracle

export ORACLE_HOME=/opt/oracle/product/21c/dbhome_1

export ORACLE_SID=agile

export ORA_INVENTORY=/opt/app/oraInventory

export PATH=$PATH:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch

export DISPLAY="localhost:10.0"

export LC_ALL=C

alias sp='sqlplus / as sysdba'

alias script='cd /u02/scripts/agile'

alias software='cd /u02/software'

alias export='cd /u02/backup/export'

当我直接执行source test,或者在shell脚本里source这个文件时,会反复抛出相同的错误:

-bash: cd: too many arguments
-bash: cd: too many arguments
-bash: cd: too many arguments
...(该错误重复多次)

我试过用.命令代替source,结果完全一样。

之后我给test文件添加了执行权限:chmod a+x ~/test,再source它时又出现了字符集相关的错误:

$ ls -ltr test
-rwxr-xr-x. 1 oracle oinstall 724 Oct  6 14:37 test

$ source test
GLib: Cannot convert message: Could not open converter from “UTF-8” to “AL32UTF8”

我尝试在test文件里添加export CHARSET=AL32UTF8这一行,再source时又回到了最初的cd: too many arguments错误。

更诡异的是,现在我source原本正常的.bash_profile也会弹出同样的cd错误,但从root用户切换到oracle用户(执行su - oracle)时却完全没问题。比如:

$ source .bash_profile
-bash: cd: too many arguments
...(大量重复的错误信息)

而以root身份source这个文件却没有任何问题:

[root@ ~]# source ~oracle/test

有没有大佬能帮我分析下到底哪里出问题了?

备注:内容来源于stack exchange,提问作者Pepe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 11:53:05