- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- diff return codes
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 06:44 AM
02-11-2011 06:44 AM
diff return codes
- Tags:
- diff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 07:02 AM
02-11-2011 07:02 AM
Re: diff return codes
the SUN man pages tell (no HP at hand here)
0 No diffs
1 Diffs
>1 Error
Many commands use '2' for ENOENT - errors 'no such file or directory'.
For me the return values mentioned are succifient (Bourne-shell syntax):
case $? in
0) print same;;
1) print diff;;
*) pint error;;
esac
BTW: I prefer 'cmp -s' for a testing of identical file content:
if cmp -s f1 f2; then print same;fi
- 'cmp' quits after the first mismatch, which is good for large files
- In most cases I do not need a listing of the differences; cmp -s just sets return codes.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 07:11 AM
02-11-2011 07:11 AM
Re: diff return codes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 07:23 AM
02-11-2011 07:23 AM
Re: diff return codes
Reliably, from the documents or the source
code.
If the documents don't satisfy, and the
source code is unavailable, then you're left
with experiment. How many different return
status values have you seen? Knowing
nothing, I have no reason to believe that
"diff" returns interesting values greater
than one.
Source for GNU "diff" _is_ readily available.
One of the many problems with relying on
experiment rather than the documents is that
whatever you discover could become obsolete
at the next "diff" update. Or when you move
to another system, where "diff" is different.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 07:51 AM
02-11-2011 07:51 AM
Re: diff return codes
as Steven told you - don't expect to much from retern values >1.
You can start a test series, giving diff non-existing or unreadable file(s) as 1st and/or 2nd argument, but I don't think you get something different as '2'.
I think, you should be able to do this by yourself:
diff file1 file2
case $? in
0) print same;;
1) print diff;;
*)
[ -e file1 ] || print -u2 missing file1
[ -d file1 ] && print -u2 a dir: file1
...
;;
esac
mfG Peter
PS: 1 point received - whow!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2011 09:14 AM
02-11-2011 09:14 AM
Re: diff return codes
Points awards in these forums often reveal
more about the questioner than about the
quality of the responses.
> Source for GNU "diff" [...]
A quick look suggests that it uses
EXIT_SUCCESS (0), EXIT_FAILURE (1), and
EXIT_TROUBLE (2), but there could be more in
there that I didn't notice. Code like:
[...]
int status = compare_files (NULL, from_file, argv[optind]);
if (exit_status < status)
exit_status = status;
[...]
suggests that bigger values imply bigger
problems. (But, if such stuff isn't
documented, then what good is it?)