mouss wrote:
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.
...
That again begins to go offtopic ...
What´s your interest to post here?!?
Whatever, several versions of AIX, several versions of SunOS and
Solaris, several versions of Linux (some SuSE, some RedHat, some
Debian), IRIX, True64 and 2 servers with HP-UX.
No, a "-q" is not very common :D
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?
Blub.
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
Exactly what would be normal for a unix command - for example "cp", my
friend:
# touch a b
# mkdir c
# cp a b c d
cp: target `d' is not a directory
# echo $?
1
# cp a b x c
cp: cannot stat `x': No such file or directory
# echo $?
1
# cp a b c
# echo $?
0
Where´s the problem?
But you just NEEDED to say something, right?
:)
BTW, this implementation of "cp" could also benefit from different
return codes for such different error reasons like above!