Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Apr 2006 02:03:05 -0400
From:      Parv <parv@pair.com>
To:        Garrett Cooper <youshi10@u.washington.edu>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Need /bin/sh script help
Message-ID:  <20060411060305.GA2175@holestein.holy.cow>
In-Reply-To: <443B3EF8.3020308@u.washington.edu>
References:  <443B3EF8.3020308@u.washington.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
in message <443B3EF8.3020308@u.washington.edu>,
wrote Garrett Cooper thusly...
>
> I was wondering if anyone could help me out with the following
> script I've developing (the grep if statements are incorrect..):
> 
> #!/bin/sh
> #
> 
> KC="";
> 
> cd /usr/src;
> 
> if [ -n `grep -e s/KERNCONF=/ /etc/make.conf` ] # want to look for 

Well, you did not write what exactly is the problem, as executing
the above works as expected.  Why do have 'KERNCONF' surrounded by
's/' & '/'?


In any case, there is not need to see if the returned string length
is nonzero.  Just use the grep return code & send the all the output
to /dev/null ...

  if grep -e '^KERNCONF=' /etc/make.conf >/dev/null 2>&1
  then
    ...
  fi


... or you could also use '-q' and/or '-s' grep options instead of
sending output to /dev/null.  (I personally would do a bit more
strict check to see $KERNCONF is set to value containing characters
meeting some criteria, say '\<[-._[:alnum:]]+\>'.)


> KERNCONF in /etc/make.conf
> then
>        echo "enter in the kernel conf file full pathname:";

I did not know one can specify the kernel configuration path, not
just the basename.


>        read KERNCONF;
>        KC="KERNCONF=$KERNCONF";
> fi
> 
> if [ -n `grep -e s/NO_CLEAN=*yes*/ /etc/make.conf` ] // want to look for 
                                                       ^^
                                                       ^^
                                            Wrong kind of comment
                                            character.

See above comments about grep(1) usage.


  - Parv

-- 




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060411060305.GA2175>