#!/bin/sh

# menu
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010, 2011, 2012, 2023
# Joseph Rosevear

# This file is part of The SAM Kernel.

# The SAM Kernel is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 3 of the
# License, or (at your option) any later version.

# The SAM Kernel is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.



# Joseph Rosevear 111231 I changed #!/bin/sh to #!/bin/bash.

# Joseph Rosevear 120808 I changed the prgama back to #!/bin/sh,
# because due to
# changes in SAM the sh shell will work fine.

# Joseph Rosevear 230502 I added an echo of $1 at the beginning.

# Joseph Rosevear 230512 I removed the above adding of an echo. 
# Apparently, it wasn't needed.

# Joseph Rosevear 230517 I changed the code to use shoparts to display
# the contents of sam_add

# I removed the code which displays the other, non-level, parts of the
# menu.

# I revised the menu format.

# I removed the code for the "invisible backbone".



# Definitions.
level="$1"

if [ "$level" = "" ]; then

   if [ -x $level/setcolor ]; then
   
      $level/setcolor
   fi
fi

(

   echo ""

   if [ "$sam_add" != "" ] && [ "$level" = "" ]; then

      echo -e "added:\n\n`shoparts sam_add`"
      echo ""
   fi
   
   if [ "$level" = "" ]; then

      echo -e "${level}:\n"
   fi
   
   if [ "$level" != "" ]; then

      echo -e "${1}:\n"
   fi
   
   echo  " COMMAND       DESCRIPTION"
   
   if [ "$level" = "" ]; then

      cat $level/menu.dat
   fi
   
   if [ "$level" != "" ]; then

       cat $level/menu.dat
   fi
   
   echo ""
   cat $sam_root/main/about/data/copyr.dat
   echo ""
) > $sam_temp_dir/view.dat

sam_view $sam_temp_dir/view.dat
echo ""
