@@ -459,6 +459,27 @@ static size_t handleZshKeyword (int keyword,
459
459
return vStringLength (token );
460
460
}
461
461
462
+ static bool doesLineCotinue (const unsigned char * start , const unsigned char * cp )
463
+ {
464
+ cp -- ;
465
+ if (start >= cp )
466
+ return false;
467
+
468
+ if (* cp != '\\' )
469
+ return false;
470
+
471
+ while (start < cp )
472
+ {
473
+ if (* cp == ';' || * cp == '|' || * cp == '&' )
474
+ return false;
475
+ else if (isspace (* cp ))
476
+ cp -- ;
477
+ else
478
+ return true;
479
+ }
480
+ return false;
481
+ }
482
+
462
483
static bool handleVariableAssignment (vString * input )
463
484
{
464
485
const char * base = vStringValue (input );
@@ -503,6 +524,7 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
503
524
struct hereDocParsingState hstate ;
504
525
hdocStateInit (& hstate );
505
526
527
+ bool cont_line = false;
506
528
while ((line = readLineFromInputFile ()) != NULL )
507
529
{
508
530
const unsigned char * cp = line ;
@@ -528,10 +550,12 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
528
550
vStringDelete (hereDocDelimiter );
529
551
hereDocDelimiter = NULL ;
530
552
}
553
+ cont_line = false;
531
554
continue ;
532
555
}
533
556
534
557
hdocStateClear (& hstate );
558
+ bool beginning_of_line = !cont_line ;
535
559
while (* cp != '\0' )
536
560
{
537
561
subparser * sub = NULL ;
@@ -669,6 +693,7 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
669
693
cp += d ;
670
694
else if (* cp != '\0' )
671
695
++ cp ;
696
+ beginning_of_line = false;
672
697
continue ;
673
698
}
674
699
@@ -710,7 +735,8 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
710
735
++ cp ;
711
736
}
712
737
}
713
- else if (found_kind == K_NOTHING
738
+ else if (beginning_of_line
739
+ && found_kind == K_NOTHING
714
740
&& handleVariableAssignment (name ))
715
741
found_kind = K_VARIABLE ;
716
742
@@ -729,7 +755,11 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
729
755
else if (!hereDocDelimiter )
730
756
hdocStateUpdateArgs (& hstate , name );
731
757
vStringClear (name );
758
+ beginning_of_line = false;
732
759
}
760
+ if (* cp == '#' )
761
+ cont_line = false;
762
+ cont_line = doesLineCotinue (line , cp );
733
763
}
734
764
hdocStateFini (& hstate );
735
765
vStringDelete (name );
0 commit comments