Shell script frustration

Garance A Drosehn gad at
Thu Jul 28 16:40:34 GMT 2005

At 10:10 AM +0100 7/28/05, martin at wrote:
>Garance wrote:
>  > What I do in this cases is create a script called "":
>>  #!/bin/sh
>>  printf "\ at `date +%H:%M:%S` with \$# = $#\n"
>>  # Process all parameters.
>>  N=0
>>  while test $# != 0 ; do
>>       N=$(($N+1))
>>       printf "    \$$N = [%3d] '$1'\n" ${#1}
>>       shift
>>  done
>>  Then in your script, replace the ldapdelete command with
>>  That way you'll see *exactly* what ldapdelete
>>  is seeing for parameters, and that might help.
>I tried that one, with an echo $* - though I assume the printf
>prints it out 'more precise'?

Well, I also have versions that use an echo instead of printf.
The printf just makes it easier to have a "pretty" output.

The problem with using a plain 'echo *' is that there are
several different inputs which will produce the same output.

         echo a b
     and echo "a b"
or      echo "a b"
     and echo "a b "

The outputs from `echo' will look the same, but the arguments to
the program are very different.  That's why my script lists out
the exact arguments, with their lengths.  I did that because
sometimes those details matter.  I have solved problems similar
to the one which is frustrating you by using this kind of script.

Garance Alistair Drosehn     =      gad at
Senior Systems Programmer               or   gad at
Rensselaer Polytechnic Institute;             Troy, NY;  USA

More information about the freebsd-questions mailing list