@@ -684,7 +684,14 @@ private static ClassifiedVerb ClassifyVerb(List<PwshToken> body, int start)
684684 var t = body [ i ] ;
685685 if ( t . Kind == PwshTokenKind . Parameter )
686686 {
687- if ( flagsForVerb is null || ! flagsForVerb . Contains ( StripColon ( t . Value ) ) )
687+ if ( TrySplitNativeEqualsFlag ( t . Value , out _ , out _ ) )
688+ {
689+ // Match Bash: an inline --flag=value is surfaced by
690+ // arg extraction, and terminates the greedy walk.
691+ break ;
692+ }
693+
694+ if ( flagsForVerb is null || ! flagsForVerb . Contains ( t . Value ) )
688695 {
689696 break ;
690697 }
@@ -721,12 +728,6 @@ private static ClassifiedVerb ClassifyVerb(List<PwshToken> body, int start)
721728 } ;
722729 }
723730
724- private static string StripColon ( string paramToken )
725- {
726- var colon = paramToken . IndexOf ( ':' ) ;
727- return colon > 0 ? paramToken . Substring ( 0 , colon ) : paramToken ;
728- }
729-
730731 // ---------------------------------------------------------------- args
731732
732733 private readonly struct ArgResult
@@ -800,14 +801,15 @@ private static ArgResult ExtractArgsAndRedirects(
800801 pendingNativeFlag = null ;
801802
802803 var raw = t . Value ;
803- var colon = raw . IndexOf ( ':' ) ;
804- var paramName = colon > 0 ? raw . Substring ( 0 , colon ) : raw ;
805- var colonValue = colon > 0 ? raw . Substring ( colon + 1 ) : null ;
806-
807- args . Add ( new Arg { Raw = paramName , Kind = ArgKind . Literal , IsPath = false } ) ;
808804
809805 if ( cmdletStyle )
810806 {
807+ var colon = raw . IndexOf ( ':' ) ;
808+ var paramName = colon > 0 ? raw . Substring ( 0 , colon ) : raw ;
809+ var colonValue = colon > 0 ? raw . Substring ( colon + 1 ) : null ;
810+
811+ args . Add ( new Arg { Raw = paramName , Kind = ArgKind . Literal , IsPath = false } ) ;
812+
811813 if ( colonValue is not null )
812814 {
813815 // Colon form always binds (§6.5.3 rule 1).
@@ -821,13 +823,30 @@ private static ArgResult ExtractArgsAndRedirects(
821823 }
822824 else
823825 {
824- // Native flag-with-value via the shared bash table (§7.3).
825826 var verbKey = verb . VerbTokens . Count > 0 ? verb . VerbTokens [ 0 ] : string . Empty ;
826- if ( colonValue is null
827+
828+ // Native --flag=value follows Bash exactly: surface the
829+ // flag and value separately, and classify a curated
830+ // flag's value through the shared per-verb table.
831+ if ( TrySplitNativeEqualsFlag ( raw , out var flagPart , out var valuePart ) )
832+ {
833+ args . Add ( new Arg { Raw = flagPart , Kind = ArgKind . Literal , IsPath = false } ) ;
834+ var valueIsPath = BashPerVerbRules . ValueOfFlagIsPath ( verbKey , flagPart ) ;
835+ args . Add ( ResolveValue (
836+ valuePart , valueIsPath , options , workingDirectoryUnknown , false ) ) ;
837+ }
838+ else
839+ {
840+ // A colon has no native binding meaning. Preserve the
841+ // complete option rather than dropping its tail.
842+ args . Add ( new Arg { Raw = raw , Kind = ArgKind . Literal , IsPath = false } ) ;
843+ }
844+
845+ if ( raw . IndexOf ( '=' ) < 0
827846 && BashVerbs . FlagsWithValue . TryGetValue ( verbKey , out var flags )
828- && flags . Contains ( paramName ) )
847+ && flags . Contains ( raw ) )
829848 {
830- pendingNativeFlag = paramName ;
849+ pendingNativeFlag = raw ;
831850 }
832851 }
833852
@@ -889,6 +908,29 @@ private static ArgResult ExtractArgsAndRedirects(
889908 return new ArgResult ( args , redirects , null ) ;
890909 }
891910
911+ private static bool TrySplitNativeEqualsFlag (
912+ string raw , out string flagPart , out string valuePart )
913+ {
914+ if ( raw . Length < 2 || raw [ 0 ] != '-' )
915+ {
916+ flagPart = "" ;
917+ valuePart = "" ;
918+ return false ;
919+ }
920+
921+ var equals = raw . IndexOf ( '=' ) ;
922+ if ( equals <= 0 || equals == raw . Length - 1 )
923+ {
924+ flagPart = "" ;
925+ valuePart = "" ;
926+ return false ;
927+ }
928+
929+ flagPart = raw . Substring ( 0 , equals ) ;
930+ valuePart = raw . Substring ( equals + 1 ) ;
931+ return true ;
932+ }
933+
892934 private static Arg ResolveValueToken (
893935 string raw , string logicalValue , bool treatAsPath ,
894936 PwshParserOptions options , bool workingDirectoryUnknown , bool isLiteralBytes )
0 commit comments