Bug 187322

Summary: Cleanup error handling
Product: [Fedora] Fedora Reporter: Dmitry V. Levin <ldv>
Component: setarchAssignee: Jindrich Novy <jnovy>
Status: CLOSED RAWHIDE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: pknirsch
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-04-18 12:18:38 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
setarch-1.9-owl-fixes.patch none

Description Dmitry V. Levin 2006-03-30 00:10:01 UTC
Even such small program like setarch could be cleaned up. :)

Attached patch changes setarch behaviour wrt error handling in more clean way.
Here are 7 examples (old$ is unpatched setarch, new$ is patched):

1. setarch without arguments:

old$ setarch; echo rc=$?
Usage: setarch <arch> [options] [program [program arguments]]

Options:
[options output omitted for brevity]

For more information see setarch(8).
rc=1

new$ setarch; echo rc=$?
setarch: Insufficient arguments
Try `setarch -h' for more information.
rc=1

2. setarch -h:

old$ setarch -h; echo rc=$?
Don't know how to set arch to -h
rc=1

new$ setarch -h; echo rc=$?
Usage: setarch <arch> [options] [program [program arguments]]

Options:
[options output omitted for brevity]

For more information see setarch(8).
rc=0

3. Unrecognized architecture:

old$ setarch foo; echo rc=$?
Don't know how to set arch to foo
rc=1

new$ setarch foo; echo rc=$?
setarch: foo: Unrecognized architecture
rc=1

4. linux32 without arguments:

old$ linux32; echo rc=$?
Usage: linux32 [options] [program [program arguments]]

Options:
[options output omitted for brevity]

For more information see setarch(8).
rc=1

new$ linux32; echo rc=$?
-sh-3.1$ logout
rc=0

5. unknown option:

old$ linux32 -z; echo rc=$?
warning: unknown option `z'
-sh-3.1$ logout
rc=0

new$ linux32 -z; echo rc=$?
linux32: Unknown option `z' ignored
-sh-3.1$ logout
rc=0

6. setarch exec failure

old$ setarch linux32 foo; echo rc=$?
rc=1

new$ setarch linux32 foo; echo rc=$?
setarch: foo: No such file or directory
rc=1

7. linux32 exec failure

old$ linux32 foo; echo rc=$?
rc=1

new$ linux32 foo; echo rc=$?
linux32: foo: No such file or directory
rc=1

Comment 1 Dmitry V. Levin 2006-03-30 00:10:02 UTC
Created attachment 127032 [details]
setarch-1.9-owl-fixes.patch

Comment 2 Jindrich Novy 2006-04-18 12:18:38 UTC
Applied with a few modifications, thanks.