Subject: positional parameters in wrapper scripts
To: None <>
From: Klaus Heinz <>
List: tech-pkg
Date: 06/06/2004 16:45:45

is there a way to safely delete positional parameters in a shell script?

I need to go through the list of positional parameters of a script, delete
certain parameters and pass the rest on to a program.

This sounds simple enough:

  #! /bin/sh
  echo "number of parameters: $#"
  while test $# -gt 0; do
        if test "1" = "$1"; then shift; fi
        params="$params $1"
        shift # ignore the case where $# was 1 and I shift two times
  set -- $params
  echo "number of parameters: $#"

  $ ./ 1 "2 3" 4
  number of parameters: 3
  number of parameters: 3
                       ^^^ should be 2

While "$@" preserves the parameters, I am at a loss how to change "$@".

Can anybody help me?

     Klaus Heinz