Date: Thu, 28 Jul 2005 12:40:29 -0400 From: Garance A Drosehn <gad@FreeBSD.org> To: martin@orbweavers.co.uk Cc: freebsd-questions@FreeBSD.org Subject: Re: Shell script frustration Message-ID: <p0623090abf0eb41a85ad@[128.113.24.47]> In-Reply-To: <1136.217.37.3.201.1122541837.squirrel@www.orbweavers.co.uk> References: <1559.192.168.0.10.1122502486.squirrel@192.168.0.5> <p06230909bf0dd7e0e787@[128.113.24.47]> <1136.217.37.3.201.1122541837.squirrel@www.orbweavers.co.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
At 10:10 AM +0100 7/28/05, martin@orbweavers.co.uk wrote:
>Garance wrote:
> > What I do in this cases is create a script called "list_args.sh":
>>
>> #!/bin/sh
>> printf "\nlist_args.sh 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
>> list_args.sh. 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.
Compare:
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@gilead.netel.rpi.edu
Senior Systems Programmer or gad@FreeBSD.org
Rensselaer Polytechnic Institute; Troy, NY; USA
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?p0623090abf0eb41a85ad>
