@@ -587,8 +587,8 @@ int paste(struct argblock *pbptr) {
587587 else
588588 break ;
589589 } else if (compare_argument ('t' , "type" , pbptr -> argv , & pbptr -> argv , /*out_args_consumed*/ NULL , /*option_arg_optional*/ false, & option_arg ) & option_comparison_eitheropt ) {
590- if (!type ) {
591- type = create_UTI_with_cstr (option_arg );
590+ if (!pbptr -> type ) {
591+ pbptr -> type = create_UTI_with_cstr (option_arg );
592592 if (!has_encountered_translate_newlines )
593593 pbptr -> flags .infer_translate_newlines = true;
594594 } else
@@ -621,6 +621,9 @@ int paste(struct argblock *pbptr) {
621621 has_encountered_translate_newlines = true;
622622 pbptr -> flags .infer_translate_newlines = false;
623623 pbptr -> flags .translate_newlines = false;
624+ } else if (* (* (pbptr -> argv )) == '-' ) {
625+ fprintf (stderr , "%s: Internal error: Unrecognized argument “%s”\n" , argv0 , * (pbptr -> argv ));
626+ return 1 ;
624627 } else {
625628 numericValue = strtoul (* (pbptr -> argv ), NULL , 10 );
626629 if ((numericValue > 0U ) && (numericValue < numItems )) {
@@ -640,23 +643,18 @@ int paste(struct argblock *pbptr) {
640643 if (!has_encountered_translate_newlines )
641644 pbptr -> flags .infer_translate_newlines = true;
642645 }
643- } else if ( pbptr -> out_fd < 0 ) {
646+ } else {
644647 if (filename )
645648 break ;
646- else {
649+ else
647650 filename = * ((pbptr -> argv )++ );
648- pbptr -> out_fd = open (filename , O_WRONLY | O_CREAT | O_TRUNC , 0644 );
649- }
650- } else {
651- fprintf (stderr , "%s: Internal error: Unrecognized argument “%s”\n" , argv0 , * (pbptr -> argv ));
652- return 1 ;
653651 }
654652 }
655653 }
656654
657655 these_args = * pbptr ;
658656 if (these_args_ptr -> out_fd < 0 )
659- these_args_ptr -> out_fd = STDOUT_FILENO ;
657+ these_args_ptr -> out_fd = filename ? open ( filename , O_WRONLY | O_CREAT | O_TRUNC , 0644 ) : STDOUT_FILENO ;
660658 if (!these_args_ptr -> type )
661659 these_args_ptr -> type = kUTTypeUTF8PlainText ; //Don't retain; borrow the retention by pbptr.
662660 if (!these_args_ptr -> itemIndex )
0 commit comments