
Ubuntu日本語フォーラム

ログインしていません。
お世話になります。terminalを立ち上げると次のようなエラーメッセージが表示されます。
回避方法を御教授ください。
bash: [: 引数が多すぎます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: 引数が多すぎます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
1.xubuntu12.04をアップデートして、12.10になってます。32bitのDesktop版です。
2.このエラーは、gnome-terminalでも、Guakeでも、他のterminalでも同じく表示されます。
3.terminalを立ち上げるだけで表示され、何かを実行させている訳ではありません。
4.特段、bash関連のファイルをイジったりしていません。
5.エラー表示後、terminal上での操作には、問題が発生しません。
6.$dpkg -l bashでbashのパッケージのバージョンは、4.2-5ubuntu1と表示されます。
よろしくお願いいたします。
オフライン
msam255 様へ。
> 4.特段、bash関連のファイルをイジったりしていません。
いいえ、エラーを見る限り、弄っているように思えます。
以下の 3 つのファイルを提示してください。
* ~/.bashrc
* ~/.profile
* ~/.bash_profile
一部存在しないものもあります。
オフライン
hellfire様 有難うございます。仰せのとおり、開示致します。なお、.bash_profileは存在しませんでした。
そのまんま貼り付けます。
~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
alias vi='vim'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
. /etc/bash_completion
fi
~/.profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
以上です。よろしくお願い致します。
ただ、エラーの発生は、この数日前からです。表示したファイルのタイムスタンプは、数ヶ月前の日付となっており
最近更新されたとは思えないのですが? ファイルの内容はいかがでしょうか?
オフライン
https://forums.ubuntulinux.jp/viewtopic.php?id=10330
を参考に。
STGSAGWAN様 有難うございます。参考にさせていただきました。
”script -f log.txt -c 'bash -v'”で、出力されたlog.txtでエラーが表示される箇所は
/usr/share/bash-completion/bash-completionファイルの次のスクリプトであると
思われます。
なにやら”unset BASH_COMPLETION_ORIGINAL_V_VALUE”とのことのようですが・・
しかし、残念ながらどこがどういけないのか私には解りません。
引き続き御指示お願いします。よろしくお願いいたします。
log.txt(該当部分のみ表示)
# The latest version of this software can be obtained here:
#
# http://bash-completion.alioth.debian.org/
#
# RELEASE: 1.99
if [[ $- == *v* ]]; then
BASH_COMPLETION_ORIGINAL_V_VALUE="-v"
else
BASH_COMPLETION_ORIGINAL_V_VALUE="+v"
fi
if [[ ${BASH_COMPLETION_DEBUG-} ]]; then
set -v
else
set +v
fi
bash: [: 引数が多すぎます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: 引数が多すぎます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
bash: [: =: 単項演算子が予期されます
unset BASH_COMPLETION_ORIGINAL_V_VALUE
# ex: ts=4 sw=4 et filetype=sh
オフライン
msam255 様へ。
#3 を見る限り、いじっていないようですね。
疑って申し訳ないです。
#5 を見ると、補完機能に問題があるようです。
bash の補完機能を再インストールしてみてください。
$ sudo apt-get --purge remove bash-completion $ sudo apt-get install bash-completion
オフライン
script -f log.txt -c 'bash -v'
の代わりに
script -f log.txt -c 'bash -x'
を同様にやれば、問題の箇所を特定出来るはずです。
原因を突き止める前に、システムを改変するのは、私はお勧めしないです。 もし偶然直った場合に、結局何が悪かったのか分からないです。
最初からbash -xだと膨大なログに圧倒されてどのファイルで何が実行されているのか分からないので、最初はbash -vで大雑把に、次にbash -xで絞り込むイメージ。
hellfire様 STGSAGWAN様 御返答有難うございます。
STGSAGWAN様のお説はごもっともながら、私の能力では、少々と言うか、かなり敷居が高く感じます。
御提案どおり、試して見ましたが、解決への結果が得られません。
やむなくhellfire様の御提案を実施いたしましたが、結果に変化はありませんでした。
何が影響しているのでしょうか?
しかたなくと言いますか、この際にとでもいいますか
chsh -s /bin/zsh とやりまして $ → % といたしました。こちらは、エラーなく快適です。
但し、bashのエラー環境は残っておりますので、時間をかけてじっくり取り組んで見ます。
有難うございました。また何かありましたらお世話してください。
オフライン
#5と同様に、#7の後者の『コード』を実行しexit、次にlog.txtを開き、メッセージ『bash: [: 引数が多すぎます』や『bash: [: =: 単項演算子が予期されます』という文字列を検索し、そのあたり数行を投稿するだけなんですけど。
おそらく~/.bash_completionの中身に問題があると、私は予想しています。
解決されたのでしょうか?
自分の場合には、
terminalを立ち上げると、エラーメッセージは次のもののみが表示されます。
bash: [: 引数が多すぎます
ネットを当たったのですが、解決策が見つからず、こちらに行き当たりました。初心の者ゆえよろしくお願いします。
オフライン
jazzwalker さん
それも、シェルスクリプトの構文ミスです。
おそらく、if の [ ] のあたりにミスがあるはずです。
-x オプションをつけて、追跡してみてください。
オフライン
ご返信ありがとうございます。
恐縮ですが、具体的な手順をお示しいただけませんか。慣れていないもので、済みません。
オフライン
上の
bash の補完機能を再インストール についてはやってみました(結果は変わらず)。
それ以上ということになりますと、自分のスキルではキツイものがあります。
オフライン
そもそも、ターミナルを立ち上げただけで、即(一行目に)エラーが出るのは何故なのでしょうか? 何も打ち込んではおりません。
オフライン
jazzwalker さん
jazzwalker による投稿:
そもそも、ターミナルを立ち上げただけで、即(一行目に)エラーが出るのは何故なのでしょうか? 何も打ち込んではおりません。
.bashrc や .bash_profile をいじりませんでしたか?
あるいは、これらのファイルを改変するインストーラを実行しませんでしたか?
これらのファイルは、ターミナル (シェル) 起動時に初期化する内容が書かれています。
問題は、上記ファイルの構文ミスが原因ですので、
それを直さないことにはどうしようもありません。
編集した内容などの情報があれば、対処できるのですが、
それがないことにはご自身で対処されるしかありません。
リセットするというのであれば、以下のコマンドを実行して下さい。
cp /etc/skel/.bashrc ~
新しいユーザを作る時、新しいユーザのホームディレクトリは /etc/skel からコピーされます。
上記コマンドは、問題の .bashrc を初期状態のもので上書きするコマンドです。
コマンドが使えないというのであれば、nautilus などで、/etc/skel の場所を開き、
隠しファイルを表示して、自分のホームディレクトリにコピーして下さい。
オフライン
>cp /etc/skel/.bashrc ~
ご説明ありがとうございました。上のコマンドを実行しまして、メッセージが消えました。
オフライン