intcmp(1): rewrite in rust
This commit is contained in:
@@ -16,18 +16,17 @@
|
||||
* along with this program. If not, see https://www.gnu.org/licenses/.
|
||||
*/
|
||||
|
||||
// /* 0b00? */ /* Equal | -e | 0b001 | 1 */
|
||||
// #define EQUAL 0x01 /* Greater | -g | 0b010 | 2 */
|
||||
// /* 0b0?0 */ /* Greater or Equal | -ge | 0b011 | 3 */
|
||||
// #define GREATER 0x02 /* Less | -l | 0b100 | 4 */
|
||||
// /* 0b?00 */ /* Less or Equal | -le | 0b101 | 5 */
|
||||
// #define LESS 0x04 /* Inequal (Greater or Less) | -gl | 0b110 | 6 */
|
||||
|
||||
use std::{
|
||||
env::args,
|
||||
process::ExitCode
|
||||
};
|
||||
|
||||
extern crate getopt;
|
||||
use getopt::GetOpt;
|
||||
|
||||
extern crate sysexits;
|
||||
use sysexits::EX_USAGE;
|
||||
|
||||
fn usage(s: &str) -> ExitCode {
|
||||
eprintln!("Usage: {} [-egl] integer integer...", s);
|
||||
ExitCode::from(EX_USAGE as u8)
|
||||
@@ -54,7 +53,7 @@ fn main() -> ExitCode {
|
||||
|
||||
if argv.len() - optind < 2 /* ref cmp */ { return usage(&argv[0]); }
|
||||
|
||||
let mut reference = None;
|
||||
let mut reference: Option<usize> = None;
|
||||
let mut cmpn: usize;
|
||||
|
||||
for arg in argv.iter().skip(optind) {
|
||||
@@ -72,6 +71,8 @@ fn main() -> ExitCode {
|
||||
|| (!can_lt && refn < cmpn)
|
||||
{ return ExitCode::FAILURE; }
|
||||
}
|
||||
|
||||
reference = Some(cmpn);
|
||||
}
|
||||
|
||||
ExitCode::SUCCESS
|
||||
|
||||
Reference in New Issue
Block a user