#!/bin/sh #---------------------------------------------------------------------------- # list-groups - list groups # # Creation: 2001-11-04 fm # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program 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 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi CHOOSE=/var/install/bin/choose AWK=/usr/bin/gawk MKTEMP=/usr/bin/mktemp RM=/usr/bin/rm EXPR=/usr/bin/expr #---------------------------------------------------------------------------- # main #---------------------------------------------------------------------------- main() { GROUP_TITLE='List groups' GROUP_FLAGS='--indent 12 --spread --list' GROUP_COLS='10* 7' GROUP_ROWS=0 GROUP_CAPTION_1='--info "Group"' GROUP_CAPTION_2='--info "Gid"' export GROUP_TITLE export GROUP_FLAGS export GROUP_COLS export GROUP_CAPTION_1 export GROUP_CAPTION_2 while read line do GROUP_ROWS=$(${EXPR} ${GROUP_ROWS} + 1) group="$(echo "${line}" | ${AWK} -F: '{ print $1 }')" gid="$(echo "${line}" | ${AWK} -F: '{ print $3 }')" eval GROUP_${GROUP_ROWS}_1=\"${group}\" eval GROUP_${GROUP_ROWS}_2=\"${gid}\" export GROUP_${GROUP_ROWS}_1 export GROUP_${GROUP_ROWS}_2 export GROUP_ROWS done ${_ask_tmpfile} rc=${?} read answer < ${_ask_tmpfile} ${RM} -f ${_ask_tmpfile} # if ask break, ask returned 255 if [ ${rc} = 255 ] then answer=0 fi unset GROUP_FLAGS unset GROUP_CAPTION_1 unset GROUP_CAPTION_2 case ${answer} in '') exit 0 ;; 0) exit 127 ;; esac } #---------------------------------------------------------------------------- # call function main #---------------------------------------------------------------------------- main "${@}" #---------------------------------------------------------------------------- # end #----------------------------------------------------------------------------