Commit fef6217 1 parent 395eb2b commit fef6217 Copy full SHA for fef6217
File tree 1 file changed +14
-5
lines changed
1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -401,11 +401,20 @@ pub fn cut_str<W: Write>(
401
401
BoundOrFiller :: Bound ( b) => b,
402
402
} ;
403
403
404
- let r = b. try_into_range ( num_fields) ?;
405
-
406
- let idx_start = fields[ r. start ] . start ;
407
- let idx_end = fields[ r. end - 1 ] . end ;
408
- let output = & line[ idx_start..idx_end] ;
404
+ let r = b. try_into_range ( num_fields) ;
405
+
406
+ let output = if r. is_ok ( ) {
407
+ let r = r. unwrap ( ) ;
408
+ let idx_start = fields[ r. start ] . start ;
409
+ let idx_end = fields[ r. end - 1 ] . end ;
410
+ & line[ idx_start..idx_end]
411
+ } else if b. fallback_oob . is_some ( ) {
412
+ b. fallback_oob . as_ref ( ) . unwrap ( )
413
+ } else if let Some ( generic_fallback) = & opt. fallback_oob {
414
+ generic_fallback
415
+ } else {
416
+ return Err ( r. unwrap_err ( ) ) ;
417
+ } ;
409
418
410
419
let field_to_print = maybe_replace_delimiter ( output, opt) ;
411
420
write_maybe_as_json ! ( stdout, field_to_print, opt. json) ;
You can’t perform that action at this time.
0 commit comments