Thomas a écrit :
> mouss wrote:
>> check_parameter()
>> {
>>   postconf $1 2>&1 | grep -vq "unknown parameter"
>>   return $?
>> }
>>
>> or
>>
>> check_parameter()
>> {
>>   postconf $1 2>/dev/null | grep -q =
>>   return $?
>> }
>>   
> 
> Then, you need an exit-code wrapper for "grep" too, it seems :)
> 

what version of grep do you use?

http://www.opengroup.org/onlinepubs/7990989775/xcu/grep.html
...
-q
    Quiet. Do not write anything to the standard output, regardless of
matching lines. Exit with zero status if an input line is selected.
...


> check_result() {
>    RESULT=$( grep "${1}" "${2}" 2>/dev/null )
>    [ "${RESULT}" = "" ] && return 1
>    return 0
> }
> 

this is useless. did you miss the "-q" flag to grep?

> 
> So, why not directly?
> 

and what would be the exit code for this:

$ postconf -n config_directory blahblah
postconf: warning: blahblah: unknown parameter
config_directory = /usr/local/etc/postfix


> Would be neat, great for functionality and just one line more of code ....
> 

Reply via email to