File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed
Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ pub enum SeqError {
2828 /// No arguments were passed to this function, 1 or more is required
2929 #[ error( "missing operand" ) ]
3030 NoArguments ,
31+
32+ /// Both a format and equal width where passed to seq
33+ #[ error( "format string may not be specified when printing equal width strings" ) ]
34+ FormatAndEqualWidth ,
3135}
3236
3337fn parse_error_type ( e : & ParseNumberError ) -> & ' static str {
Original file line number Diff line number Diff line change @@ -114,6 +114,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
114114 format : matches. get_one :: < String > ( OPT_FORMAT ) . map ( |s| s. as_str ( ) ) ,
115115 } ;
116116
117+ if options. equal_width && options. format . is_some ( ) {
118+ return Err ( SeqError :: FormatAndEqualWidth . into ( ) ) ;
119+ }
120+
117121 let first = if numbers. len ( ) > 1 {
118122 match numbers[ 0 ] . parse ( ) {
119123 Ok ( num) => num,
Original file line number Diff line number Diff line change @@ -19,6 +19,14 @@ fn test_no_args() {
1919 . stderr_contains ( "missing operand" ) ;
2020}
2121
22+ #[ test]
23+ fn test_format_and_equal_width ( ) {
24+ new_ucmd ! ( )
25+ . args ( & [ "-w" , "-f" , "%f" , "1" ] )
26+ . fails_with_code ( 1 )
27+ . stderr_contains ( "format string may not be specified" ) ;
28+ }
29+
2230#[ test]
2331fn test_hex_rejects_sign_after_identifier ( ) {
2432 new_ucmd ! ( )
You can’t perform that action at this time.
0 commit comments