The trap command is a ksh builtin.
ksh type trap
trap is a shell builtin
Ignoring trap for the moment, there is an issue in this menu script where it calls itself. It will eventially fail because the shells will be nested too deep.
The following construct using shell functions and "return" is better:
#!/usr/bin/ksh
main_menu()
{
while true
do
clear
echo
print "CSIA RBAC -- CONFIGURACION --"
echo
print "1) Habilitar/Desabilitar RBAC en el sistema"
print "2) Configurar comandos privados"
print "6) Salir"
echo
echo "Seleccione la opcion:"
echo
read SELECT
case $SELECT in
1) menu_1
;;
2) menu_2
;;
6) return
;;
esac
done
}
#
menu_1()
{
while true
do
print "a) Habilitar RBAC?"
print "b) Desabilitar RBAC?"
echo
echo "Seleccione la opcion:"
echo
read SELECT2
case $SELECT2 in
"a") print "Habilitando RBAC"
sleep 2
return
;;
"b") print "Desabilitando RBAC"
sleep 2
return
;;
"") return
;;
*) print "Invalid"
sleep 2
;;
esac
done
}
#
menu_2()
{
while true
do
print "a) Listar los comandos privilegiados activos"
print "b) Anadir comando a RBAC"
print "c) Eliminar comando a RBAC"
echo
echo "Seleccione la opcion:"
echo
read SELECT2
case $SELECT2 in
"a") echo "Comandos activos:" && lssecattr -c ALL|grep csia|awk
'{print $1}'
sleep 2
return
;;
"b") ./addcmdrbac.ksh
sleep 2
return
;;
"c") ./delcmdrbac.ksh
sleep 2
return
;;
"") return
;;
*) print "Invalid"
sleep 2
;;
esac
done
}
#
#######
main_menu
exit