Pour voir si l'un de vos alias est en conflit avec une commande bash intégrée ou une commande système, utilisez ce script :
#!/bin/bash -i
# NAME: alias-check
# PATH: /mnt/e/bin
# DESC: Verify alias doesn't conflict with bash built-in
# DATE: June 17, 2018.
# Get aliases
alias > /tmp/alias.lst
sed -i 's/=.*//; s/alias //g' /tmp/alias.lst
#cat /tmp/alias.lst
while read -r line
do
command type -a ${line}
done< /tmp/alias.lst
Tester les mauvais alias
Editar ~/.bashrc
et insérer ces "mauvais" alias :
alias fi=find
alias test='ls test'
Exécutez maintenant le script. alias-check
:
bash: /home/rick/.bashrc: line 171: syntax error: unexpected end of file
alert is aliased to `notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e 's/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//')"'
cdd is aliased to `cd /home/rick/SERVER/#/Dump'
cdh is aliased to `cd /home/rick'
cdm is aliased to `cd /media/rick/ST9_Win7/Users/Person/Music/iTunes/iTunes Media/Music'
egrep is aliased to `egrep --color=auto'
egrep is /bin/egrep
fgrep is aliased to `fgrep --color=auto'
fgrep is /bin/fgrep
fi is aliased to `find'
fi is a shell keyword
grep is aliased to `grep --color=auto'
grep is /bin/grep
l is aliased to `ls -CF'
la is aliased to `ls -A'
ll is aliased to `ls -alF'
ls is aliased to `ls --color=auto'
ls is /bin/ls
lsdrv is aliased to `lsblk -o NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE,MODEL'
redalert is aliased to `notify-send --urgency=critical -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e 's/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//')"'
sudo is aliased to `sudo '
sudo is /usr/bin/sudo
test is aliased to `ls test'
test is a shell builtin
test is /usr/bin/test
zenity is aliased to `zenity 2>/dev/null'
zenity is /mnt/e/usr/local/bin/zenity
zenity is /usr/local/bin/zenity
zenity is /usr/bin/zenity
Remarquez les lignes :
- fi est un Shell.
- est un Shell builtin
Recherchez ce type d'erreurs dans vos alias.
Après les tests, n'oubliez pas de supprimer les alias. fi
y test
et sauvegarder ~/.bashrc
encore une fois.
Vous ne pouvez pas exécuter le test en lançant simplement alias à la ligne de commande parce que la première ligne du script est la suivante #!/bin/bash -i
charge un nouveau Shell à l'aide de ~/.bashrc
.