v_list_sys_shells 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # info: list system shells
  3. # options: [format]
  4. #
  5. # The function for obtaining the list of system shells.
  6. #----------------------------------------------------------#
  7. # Variable&Function #
  8. #----------------------------------------------------------#
  9. # Argument defenition
  10. format=${1-shell}
  11. # Includes
  12. source $VESTA/func/main.sh
  13. # Json function
  14. json_list_sh() {
  15. shells=$(cat /etc/shells)
  16. sh_counter=$(echo "$shells" | wc -l)
  17. i=1
  18. echo '['
  19. for shell in $shells; do
  20. shell=$(basename $shell)
  21. if [ "$i" -lt "$sh_counter" ]; then
  22. echo -e "\t\"$shell\","
  23. else
  24. echo -e "\t\"$shell\""
  25. fi
  26. (( ++i))
  27. done
  28. echo "]"
  29. }
  30. # Shell function
  31. shell_list_sh() {
  32. shells=$(cat /etc/shells)
  33. if [ -z "$nohead" ]; then
  34. echo "SHELLS"
  35. echo "----------"
  36. fi
  37. for shell in $shells; do
  38. shell=$(basename $shell)
  39. echo "$shell"
  40. done
  41. }
  42. #----------------------------------------------------------#
  43. # Action #
  44. #----------------------------------------------------------#
  45. # Listing domains
  46. case $format in
  47. json) json_list_sh ;;
  48. plain) nohead=1; shell_list_sh ;;
  49. shell) shell_list_sh ;;
  50. *) check_args '1' '0' '[format]' ;;
  51. esac
  52. #----------------------------------------------------------#
  53. # Vesta #
  54. #----------------------------------------------------------#
  55. exit