extfs



Hi,

I have written two new files to make writing secure, robust extfs shell scripts easier. I have not yet tested them.

Thoughts?

Roland
#! @SHELL@
#
# {Description}
#
# Written by:
#   {Name} <{Mail}>, {Year}.
#

. "@datadir@/mc/exfs/extfs.subr.sh"

mcextfs_list() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`

}

mcextfs_copyout() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`
  member="$2";  qmember=`mcextfs_quote "$2"`
  file="$3";    qfile=`mcextfs_quote "$3"`

}

mcextfs_copyin() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`
  member="$2";  qmember=`mcextfs_quote "$2"`
  file="$3";    qfile=`mcextfs_quote "$3"`

}

mcextfs_rm() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`
  member="$2";  qmember=`mcextfs_quote "$2"`

}

mcextfs_mkdir() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`
  member="$2";  qmember=`mcextfs_quote "$2"`

}

mcextfs_rmdir() {
  archive="$1"; qarchive=`mcextfs_quote "$1"`
  member="$2";  qmember=`mcextfs_quote "$2"`

}

mcextfs_init
mcextfs_main
# Common subroutines for extfs shell scripts
#
# Written by:
#   Roland Illig <roland illig gmx de>, 2004.
#

# Usable commands
AR='@AR@'
AWK='@AWK@'
EGREP='@EGREP@'
LN_S='@LN_S@'
MKDIR_P='@mkdir_p@'
PERL='@PERL@'
UNZIP='@UNZIP@'
ZIP='@ZIP@'

mcextfs_init() {
  unset LC_{ALL,COLLATE,CTYPE,MONETARY,MESSAGES,NUMERIC,TIME} LANG LANGUAGE
}

# mcextfs_quote $fname
mcextfs_quote() {
  case "$1" in
    [A-Za-z0-9_./]*)
      echo "$1";;
    *)
      echo "./$1";;
  esac
}

mcextfs_usage() {
  { echo "usage:"
    echo "  $0 list <archive>"
    echo "  $0 copyout <archive> <member> <outfile>"
    echo "  $0 copyin <archive> <member> <infile>"
    echo "  $0 rm <archive> <member>"
    echo "  $0 mkdir <archive> <member>"
    echo "  $0 rmdir <archive> <member>"
  } 1>&2
  exit 1
}

mcextfs_main() {
  if test $# -eq 0; then
    mcextfs_usage()
  fi
  case "$1" in
    list)
      test $# -ne 3 && mcextfs_usage || mcextfs_list "$2" "$3";;
    copyout)
      test $# -ne 4 && mcextfs_usage || mcextfs_copyout "$2" "$3" "$4";;
    copyin)
      test $# -ne 4 && mcextfs_usage || mcextfs_copyin "$2" "$3" "$4";;
    rm)
      test $# -ne 3 && mcextfs_usage || mcextfs_rm "$2" "$3";;
    mkdir)
      test $# -ne 3 && mcextfs_usage || mcextfs_mkdir "$2" "$3";;
    rmdir)
      test $# -ne 3 && mcextfs_usage || mcextfs_rmdir "$2" "$3";;
    *)
      mcextfs_usage;;
  esac
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]