@@ -512,6 +512,27 @@ static size_t handleZshKeyword (int keyword,
512512 return vStringLength (token );
513513}
514514
515+ static bool doesLineCotinue (const unsigned char * start , const unsigned char * cp )
516+ {
517+ cp -- ;
518+ if (start >= cp )
519+ return false;
520+
521+ if (* cp != '\\' )
522+ return false;
523+
524+ while (start < cp )
525+ {
526+ if (* cp == ';' || * cp == '|' || * cp == '&' )
527+ return false;
528+ else if (isspace (* cp ))
529+ cp -- ;
530+ else
531+ return true;
532+ }
533+ return false;
534+ }
535+
515536static bool handleVariableAssignment (vString * input )
516537{
517538 const char * base = vStringValue (input );
@@ -556,6 +577,7 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
556577 struct hereDocParsingState hstate ;
557578 hdocStateInit (& hstate );
558579
580+ bool cont_line = false;
559581 while ((line = readLineFromInputFile ()) != NULL )
560582 {
561583 const unsigned char * cp = line ;
@@ -581,10 +603,12 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
581603 vStringDelete (hereDocDelimiter );
582604 hereDocDelimiter = NULL ;
583605 }
606+ cont_line = false;
584607 continue ;
585608 }
586609
587610 hdocStateClear (& hstate );
611+ bool beginning_of_line = !cont_line ;
588612 while (* cp != '\0' )
589613 {
590614 subparser * sub = NULL ;
@@ -722,6 +746,7 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
722746 cp += d ;
723747 else if (* cp != '\0' )
724748 ++ cp ;
749+ beginning_of_line = false;
725750 continue ;
726751 }
727752
@@ -763,7 +788,8 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
763788 ++ cp ;
764789 }
765790 }
766- else if (found_kind == K_NOTHING
791+ else if (beginning_of_line
792+ && found_kind == K_NOTHING
767793 && handleVariableAssignment (name ))
768794 found_kind = K_VARIABLE ;
769795
@@ -782,7 +808,11 @@ static void findShTagsCommon (size_t (* keyword_handler) (int,
782808 else if (!hereDocDelimiter )
783809 hdocStateUpdateArgs (& hstate , name );
784810 vStringClear (name );
811+ beginning_of_line = false;
785812 }
813+ if (* cp == '#' )
814+ cont_line = false;
815+ cont_line = doesLineCotinue (line , cp );
786816 }
787817 hdocStateFini (& hstate );
788818 vStringDelete (name );
0 commit comments