#!/bin/sh

# mshow
# Copyright (C) 2025 Joseph Rosevear, San Diego CA, USA.

# This file is part of a distribution SAM.

# SAM 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.

# SAM 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 I wrote this function definition.

# Joseph Rosevear 231230 I added code to allow it work for types text
# (the default) and pdf.

# Joseph Rosevear 231231 I changed "base" to "target".  I added "local
# target".  I changed "sam_type" to "type".

# I removed the one use of ".".

# I changed the special invocation of type_set.

# I changed this to a script.

# Joseph Rosevear 240101 I changed "sam_view" to "viewer".

# Joseph Rosevear 240112 I added "2>/dev/null" to the ls invocation.

# Joseph Rosevear 240112 I added "| sort -V" to the ls invocation.

# Joseph Rosevear 240125 I changed "ls" to "ls -la".

# Joseph Rosevear 240702 I changed the sort to use "-k 9"



# Definitions.
target="$1"

# Loop?
if [ "$type" = "all" ]; then

   for string in `type=$type type_set`; do

      echo
      type=$string mshow $target
   done

else

   type_set

   echo target: $target
   echo type: $type
   echo viewer: $viewer 
   echo suf: $suf
   echo

   cdfar $level/data
   ls -la ${target}${suf}* 2>/dev/null | sort -k 9 -V 
   away
fi
