mirror of
https://github.com/serghey-rodin/vesta.git
synced 2024-12-03 19:00:24 -08:00
80 lines
1.6 KiB
Bash
Executable File
80 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# info: list system shells
|
|
# options: [FORMAT]
|
|
#
|
|
# The function for obtaining the list of system shells.
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Variable&Function #
|
|
#----------------------------------------------------------#
|
|
|
|
# Argument definition
|
|
format=${1-shell}
|
|
|
|
# Includes
|
|
source $VESTA/func/main.sh
|
|
|
|
# JSON list function
|
|
json_list() {
|
|
sh_counter=$(echo "$shells" | wc -l)
|
|
i=1
|
|
echo '['
|
|
for shell in $shells; do
|
|
if [ "$i" -lt "$sh_counter" ]; then
|
|
echo -e "\t\"$shell\","
|
|
else
|
|
echo -e "\t\"$shell\""
|
|
fi
|
|
(( ++i))
|
|
done
|
|
echo "]"
|
|
}
|
|
|
|
# SHELL list function
|
|
shell_list() {
|
|
echo "SHELL"
|
|
echo "-----"
|
|
for shell in $shells; do
|
|
echo "$shell"
|
|
done
|
|
}
|
|
|
|
# PLAIN list function
|
|
plain_list() {
|
|
for shell in $shells; do
|
|
echo "$shell"
|
|
done
|
|
}
|
|
|
|
# CSV list function
|
|
csv_list() {
|
|
echo "SHELL"
|
|
for shell in $shells; do
|
|
echo "$shell"
|
|
done
|
|
}
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Action #
|
|
#----------------------------------------------------------#
|
|
|
|
# Defining system shells
|
|
shells=$(grep -v '#' /etc/shells |awk -F '/' '{print $NF}' |sort -u)
|
|
|
|
# Listing data
|
|
case $format in
|
|
json) json_list ;;
|
|
plain) plain_list ;;
|
|
csv) csv_list ;;
|
|
shell) shell_list ;;
|
|
esac
|
|
|
|
|
|
#----------------------------------------------------------#
|
|
# Vesta #
|
|
#----------------------------------------------------------#
|
|
|
|
exit
|