@@ -116,6 +116,21 @@ pub fn is_math_expression_like(working_set: &mut StateWorkingSet, span: Span) ->
116116 is_range
117117}
118118
119+ fn is_env_variable_name ( bytes : & [ u8 ] ) -> bool {
120+ if bytes. is_empty ( ) || !bytes. is_ascii ( ) {
121+ return false ;
122+ }
123+
124+ let first = bytes[ 0 ] ;
125+ if !first. is_ascii_alphabetic ( ) && first != b'_' {
126+ return false ;
127+ }
128+
129+ bytes
130+ . iter ( )
131+ . all ( |& b| b. is_ascii_alphanumeric ( ) || b == b'_' )
132+ }
133+
119134fn is_identifier ( bytes : & [ u8 ] ) -> bool {
120135 bytes. iter ( ) . all ( |x| is_identifier_byte ( * x) )
121136}
@@ -5851,21 +5866,16 @@ pub fn parse_expression(working_set: &mut StateWorkingSet, spans: &[Span]) -> Ex
58515866
58525867 let split = name. splitn ( 2 , |x| * x == b'=' ) ;
58535868 let split: Vec < _ > = split. collect ( ) ;
5854- if !name. starts_with ( b"^" )
5855- && split. len ( ) == 2
5856- && !split[ 0 ] . is_empty ( )
5857- && !split[ 0 ] . ends_with ( b".." )
5858- // was range op ..=
5859- {
5869+ if !name. starts_with ( b"^" ) && split. len ( ) == 2 && !split[ 0 ] . is_empty ( ) {
58605870 let point = split[ 0 ] . len ( ) + 1 ;
58615871
5862- let starting_error_count = working_set. parse_errors . len ( ) ;
5863-
58645872 let lhs_span = Span :: new ( spans[ pos] . start , spans[ pos] . start + point - 1 ) ;
5865- if !is_identifier ( working_set. get_span_contents ( lhs_span) ) {
5873+ if !is_env_variable_name ( working_set. get_span_contents ( lhs_span) ) {
58665874 break ;
58675875 }
58685876
5877+ let starting_error_count = working_set. parse_errors . len ( ) ;
5878+
58695879 let lhs = parse_string_strict ( working_set, lhs_span) ;
58705880 let rhs = if spans[ pos] . start + point < spans[ pos] . end {
58715881 let rhs_span = Span :: new ( spans[ pos] . start + point, spans[ pos] . end ) ;
0 commit comments