[linux] getopts: wat doe ik fout?

Hans Paijmans j.j.paijmans op uvt.nl
Di Jan 16 17:35:31 CET 2007


Normaliter heb ik geen problemen met getopts, maar opeens zit de klad
erin. Ik zit al de hele middag met het volgende te spelen. Het dichst
bij normaal is de volgende, maar dan wordt de eerste echte parameter
niet meer goed gelezen.

dus:

$ hoppa -ac bla
db:  -ac
columns 1
tags
standoff
tekst 1
list

of
$ hoppa bla
db:  bla
columns
tags
standoff
tekst
list


------------------------------
#!/bin/sh

while getopts "achltTdsmr:v:n:" options; do
  case $options in
    a ) tekst=1 ;; # shift ;
# a ) tekst=1 ; shift ;;
    c ) columns=1 ;; # shift ;;
    h ) help ;; # shift ;;
    l ) list=1 ;; #shift ;;
    t ) tags=1 ;; #shift ;;
    T ) tags=2 ;; #shift ;;
    r ) selectie=$OPTARG ; shift 2 ;;
    v ) voorwindow=$OPTARG ; shift 2 ;;
    n ) nawindow=$OPTARG ; shift 2 ;;
    d ) debug=1 ;; #shift;;
    s ) standoff=1 ;; #shift ;;
    m ) modifications ;; #shift ;;
    --) shift ; break ;;
     *) echo "Internal error!" ; exit 1 ;;

  esac
done

echo "db: " $1

echo "columns "$columns
echo "tags "$tags
echo "standoff "$standoff
echo "tekst "$tekst
echo "list "$list

-- 
Dr. J.J. Paijmans
Tilburg University: Dept. of Linguistics & AI               013-4662693
Rijksdienst voor Archeologie, Cultuurlandchap en Monumenten 033-4227591
Maastricht University: IKAT, Faculty of General Sciences    043-3883477
Thuis: Kleine St.Jansstraat 3, 3811 HV  Amersfoort          033-4722579
http://paai.uvt.nl     http://paijmans.net         GSM: +31 621 961 083





More information about the Linux mailing list