-bash: [: 1: unary operator expected
Herhangi bir fikir?
-bash: [: 1: unary operator expected
Herhangi bir fikir?
Bu benim yaptığım zaman, benim için çalışıyor:
neyse, için en yaygın nedeni
if [ 1 = $MYVAL ]
ve sizin MYVAL
ayarlı değil: hata gibi kabuk komut dosyası kodunda olması "[: 1 tekli operatör beklenen". Tamamlama fonksiyonlarınızı kontrol edin. Hata ayıklamak için set -x
'u ekleyebilirsiniz.
Genellikle kolay çözüm operatör boş argüman alacak böylece değişken alıntı yapmak, ancak argümanlar doğru sayıda sahip olacak: Ben de bu sorun vardı ve her Google arama beni geri kurşun
if [ 1 = "$MYVAL" ]
bu gönderi.
Ben Michal'ın cevabı ve Daenyth yorumuna kullanarak bulundu çözüm ilanıyla...
My git-flow.bash aynıydı ama bizim git tamamlama dosyaları değişen olabileceğini düşünüyorum.
# __git_find_on_cmdline requires 1 argument
__git_find_on_cmdline()
{
local word subcommand c=1
while [ $c -lt $cword ]; do
word="${words[c]}"
for subcommand in $1; do
if [ "$subcommand" = "$word" ]; then
echo "$subcommand"
return
fi
done
c=$((++c))
done
}
Yeni:
# __git_find_on_cmdline requires 1 argument
__git_find_on_cmdline()
{
local word subcommand c=1
while [[ $c -lt $cword ]]; do
word="${words[c]}"
for subcommand in $1; do
if [ "$subcommand" = "$word" ]; then
echo "$subcommand"
return
fi
done
c=$((++c))
done
}
Bildirim ben eklemek zorunda çift braket
benim git tamamlama dosyası/etc/bash_completion.d/git
Eski bulunan değiştirmek vardı Bunu düzeltmek için yeni kod. Yaptığım tek değişiklik buydu.
benim için çalışmadı, hala aynı hata ile [: 1: tekli operatör bekleniyor – decebal
Neden sadece git-flow-completion kullanıyorsunuz? bash için talimatlar verilmiştir:
$ cd /etc/bash_completion.d
$ sudo wget https://raw.githubusercontent.com/bobthecow/git-flow-completion/master/git-flow-completion.bash
$ exec $SHELL
da zsh veya fish için talimatlar vardır.
alias gn="git-number"
alias gb="gn -c git blame"
alias ge="gn -c $EDITOR"
alias ga="gn add"
alias gr="gn -c git reset"
alias gap="EDITOR='$EDITOR -w' gn add -p"
alias gd="gn -c git diff -b -w --ignore-blank-lines"
alias gds="gd --staged"
alias gc="gn -c git checkout"
alias gcf="git flow feature checkout"
alias gl="gn -c git log -w -b -p --ignore-blank-lines"
alias gls="git log --stat"
alias cm="EDITOR='$EDITOR -w' git commit"
alias grb="git stash save 'REBASE' && EDITOR='$EDITOR -w' git rebase -i"
alias grbc="EDITOR='$EDITOR -w' git rebase --continue"
gcd() {
test -n "$1" && cd $(dirname $(git list $1))
}
source ~/.git-completion.bash
__git_complete gn _git
__git_complete ga _git_add
__git_complete gap _git_add
__git_complete gd _git_diff
__git_complete gds _git_diff
__git_complete gc _git_checkout
__git_complete gcf _git_checkout
__git_complete gl _git_log
__git_complete gls _git_log
__git_complete cm _git_commit
source ~/.git-flow-completion.bash
Ve completion
komut dosyalarını yüklemek: o bash olduğu için https://github.com/holygeek/git-number Sadece ~/bin
için repo en ikilileri kopyalamak :
Git sayıdır burada kaydetti – Daenyth