Скрыть
А почему говорят, что bash - УГ?
Посмотрите на этот код, разве он не прекрасен?
]
#!/bin/bash
case "$1" in
list ) case "$2" in
"" ) echo "List of the installed repositories"
echo -e $( color ltyellow) " Repo:t t t Proto:t Address:" $( color off)
echo -en $( color ltgreen) " * maint t t [Rsync ] (`cat /etc/portage/repo.d/current | sed 's/"//g'` )" $( color off)
layman -l
exit 0
;;
all ) echo "List of the available repositories"
echo -en $( color ltyellow) " Repo:t t t Proto:t Address:" $( color off)
layman -Lq
exit 0
;;
main ) echo "List of the installed main repositories"
echo -e $( color ltyellow) " Repo:t t t t t Address:" $( color off)
echo -e $( color ltgreen) " currentt t t t (`cat /etc/portage/repo.d/current | sed 's/"//g'` )" $( color off)
ls -1r / etc/ portage/ repo.d | grep -v current > / tmp/ repo_main_list
repo_count =` wc -l / tmp/ repo_main_list | cut -d ' ' -f1`
while [ "$repo_count " ! = 0 ] ; do
repo_name =` sed $repo_count ! d / tmp/ repo_main_list`
echo -e " $repo_name t t t t (`cat /etc/portage/repo.d/"$repo_name" | sed 's/"//g'` )"
let "repo_count-=1"
done
rm / tmp/ repo_main_list
echo ""
;;
esac
;;
add ) case "$2" in
"" ) echo -e "Usage:t t repo add <repo_name> <repo_address> <depo_address>"
exit 1
;;
* ) if layman -i "$2" &>/ dev/ null
then
if layman -a "$2"
then
echo "*/*::" $2 " ~amd64" > / etc/ portage/ branch.d/ "$2"
ln -s / etc/ portage/ branch.d/ "$2" / etc/ portage/ package.keywords/ "$2"
echo $( color ltgreen) "Repository " $2 " successfully added" $( color off)
else
echo "Fail"
exit 1
fi
elif [ -z "$3" ]
then
echo "Please, specify repo address"
exit 1
elif [ -z "$4" ]
then
echo "Please, specify depo address"
exit 1
elif [ -f / etc/ portage/ repo.d/ "$2" ]
then
echo "Repo " $2 " has been added already"
exit 1
elif echo "$3" | grep 'rsync' &>/ dev/ null
then
echo "$3" > / etc/ portage/ repo.d/ "$2"
sed -i 's/(.*)/"1"/' / etc/ portage/ repo.d/ "$2"
echo "$4" > / etc/ portage/ depo.d/ "$2"
sed -i 's/(.*)/"1"/' / etc/ portage/ depo.d/ "$2"
echo $( color ltgreen) "Repo " $2 " has been added" $( color off)
else
echo "Incorrect repo address"
exit 1
fi
;;
esac
;;
delete ) case "$2" in
"" ) echo -e "Usage:t t repo delete <repo_name>"
exit 1
;;
* ) if [ -f / etc/ portage/ repo.d/ "$2" ]
then
rm / etc/ portage/ repo.d/ "$2"
rm / etc/ portage/ depo.d/ "$2"
echo $( color ltgreen) "Repo " $2 " has been deleted" $( color off)
elif [ -f / etc/ portage/ branch.d/ "$2" ]
then
layman -d "$2"
rm / etc/ portage/ package.keywords/ "$2"
rm / etc/ portage/ branch.d/ "$2"
echo $( color ltgreen) "Repo " $2 " has been deleted" $( color off)
else
echo $( color ltred) "Repo " $2 " not found!" $( color off)
exit 1
fi
;;
esac
;;
sync ) case "$2" in
"" | all ) echo $( color ltyellow) "Sync all repos:" $( color off)
emerge --sync
layman -S
emerge --metadata
;;
main ) echo $( color ltyellow) "Sync main repo:" $( color off)
emerge --sync
emerge --metadata
;;
* ) if [ -f / etc/ portage/ branch.d/ "$2" ]
then
echo $( color ltyellow) "Sync " $2 " repo:" $( color off)
layman -s "$2"
emerge --metadata
else
echo $( color ltred) "Repo " $2 " not found!" $( color off)
exit 1
fi
;;
esac
;;
branch ) arch_type_raw =` cat / etc/ portage/ arch | sed 's/"//g' | cut -d '-' -f1`
if [ "$arch_type_raw " = "x86_64" ]
then
arch_type ="amd64"
else
arch_type ="x86"
fi
branch_conv( )
{
case "$1" in
"$arch_type " ) branch_name ="low"
;;
~"$arch_type " ) branch_name ="high"
;;
** ) branch_name ="top"
;;
esac
}
case "$2" in
"" | list ) echo $( color ltyellow) "Available branches:" $( color off)
echo -e "Lowt t - old stable packages ('arch' in Gentoo)"
echo -e "Hight t - new testing packages, default value ('~arch' in Gentoo)"
echo -e "Topt t - newest experimental packages, not recommended ('**' in Gentoo)"
echo ""
;;
all ) echo -e $( color ltyellow) " Repo:t t t t Branch:" $( color off)
old_branch_name =` cat / etc/ portage/ branch.d/ main | sed 's/"//g' `
branch_conv $old_branch_name
echo -e $( color ltgreen) " maint t t t " $branch_name "" $( color off)
ls -1r / etc/ portage/ branch.d | grep -v main > / tmp/ repo_list
repo_count_b =` wc -l / tmp/ repo_list | cut -d ' ' -f1`
while [ "$repo_count_b " ! = 0 ] ; do
repo_name_b =` sed $repo_count_b ! d / tmp/ repo_list`
old_branch_name_1 =` cat / etc/ portage/ branch.d/ "$repo_name_b " | cut -d ' ' -f2`
branch_conv $old_branch_name_1
echo -e " " $repo_name_b "t t t t " $branch_name ""
let "repo_count_b-=1"
done
rm / tmp/ repo_list
echo ""
;;
* ) if [ -f / etc/ portage/ branch.d/ "$2" ]
then
if [ -z "$3" ]
then
old_branch_name_2 =` cat / etc/ portage/ branch.d/ "$2" | cut -d ' ' -f2`
branch_conv $old_branch_name_2
echo -e $( color ltyellow) " Repo:t t t t Branch:" $( color off)
echo -e " " $2 "t t t t " $branch_name ""
else
case "$3" in
low ) rm / etc/ portage/ branch.d/ "$2"
echo "*/*::" $2 " " $arch_type "" > / etc/ portage/ branch.d/ "$2"
echo $( color ltgreen) "Repo " $2 " uses " $3 " branch now" $( color off)
;;
high ) rm / etc/ portage/ branch.d/ "$2"
echo "*/*::" $2 " ~" $arch_type "" > / etc/ portage/ branch.d/ "$2"
echo $( color ltgreen) "Repo " $2 " uses " $3 " branch now" $( color off)
;;
top ) rm / etc/ portage/ branch.d/ "$2"
echo "*/*::" $2 " **" > / etc/ portage/ branch.d/ "$2"
echo $( color ltgreen) "Repo " $2 " uses " $3 " branch now" $( color off)
;;
* ) echo $( color ltred) "Unknown branch!" $( color off)
;;
esac
fi
else
echo $( color ltred) "Repo not found!" $( color off)
fi
echo ""
;;
esac
;;
esac
exit 0
Re:А почему говорят, что bash - УГ?
блять, ну что за ёптваюмать у вас тут с автоформатированием?
;>, ;5BOI55 =0 :@K;LOE =>G8