hehe :D

easy as hell, one has to enclose argument of parse_cmdline into brackets :)

parse_cmdline "$@"

sorry for noise

On Mon, Aug 31, 2009 at 1:07 AM, Stefan Miklosovic <
miklosovic.free...@gmail.com> wrote:

> hi,
>
> assuming I execute shell script like this
>
> $ ./script -c "hello world"
>
> I want to save "hello world" string to variable COMMENT in shell script.
>
> code:
>
> #!/bin/sh
>
> parse_cmdline() {
>     while [ $# -gt 0 ]; do
>         case "$1" in
>             -c)
>                 shift
>                 COMMENT="$1"
>                 ;;
>         esac
>         shift
>     done
> }
>
> parse_cmdline $*
>
> echo $COMMENT
>
> exit 0
>
> but that only write out "hello". I tried to change $* to $@, nothing
> changed.
>
> It is interesting, that if I dont put "while" loop into function
> parse_cmdline,
> and do echo $COMMENT, it writes "hello world".
>
> I WANT that function style. How to do it ?
>
> thank you
>
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"

Reply via email to