Seems to be valid claim. I am able to reproduce, and also see that in BladeLogic 8.2, grep returns 0 when file does not exist.
if this is something you must have fixed, file a ticket so that engineering can supply a hotfix; otherwise use another condition to check for file existence and return 1 as before or 2 as in linux:
[ -f /path/to/file ] && grep "string" /path/to/file || return 1
if [ -f /path/to/file ]
grep "string" /path/to/file
But why the difference when it worked ok under 7.5 and now means a rewrite of hundreds of scripts in use or we just dont upgrade. We have a case raised so waitng on a responce as it has been replicated.
must be some change in the nsh utilities, but do not know why. if you get the reason for it from the work on the ticket please post.
So as we are only just moving to 8.1 and its been around for some time as an issue including the new 8.2 surely other users have seen this issue so how have people got round this without recoding 100's of scripts etc?
I did a quick scan through old issues / defects, but didn't find any obvious issues of this reported (I could have missed), so perhaps not too many users rely on nsh grep reporting about missing file in a fashion that this could affect them. They could have:
- checked for file existence first
- not check the exit code of grep
- used remote rather than central execution, where linux grep is used
- fixed issue themselves and not file a ticket
This is obviously hypothetical, but I do not have a better answer.
BMC have advised it is an issue in 8.1 & 8.2 and are looking at a fix for us, as we have hundreds of scripts we would need to re-write otherwise and retest across multiple environments
QM001770943 - grep return code incorrect
Fix targeted for 8.2 SP4
1 of 1 people found this helpful
We have had the fix direct for 8.1 as we raised the issue and it resolves the issue.